]>
Commit | Line | Data |
---|---|---|
0e5a7faa CR |
1 | /* |
2 | * "git reset" builtin command | |
3 | * | |
4 | * Copyright (c) 2007 Carlos Rica | |
5 | * | |
6 | * Based on git-reset.sh, which is | |
7 | * | |
8 | * Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano | |
9 | */ | |
f8adbec9 | 10 | #define USE_THE_INDEX_COMPATIBILITY_MACROS |
c2e86add | 11 | #include "builtin.h" |
b2141fc1 | 12 | #include "config.h" |
697cc8ef | 13 | #include "lockfile.h" |
0e5a7faa CR |
14 | #include "tag.h" |
15 | #include "object.h" | |
cf394719 | 16 | #include "pretty.h" |
0e5a7faa CR |
17 | #include "run-command.h" |
18 | #include "refs.h" | |
19 | #include "diff.h" | |
20 | #include "diffcore.h" | |
21 | #include "tree.h" | |
c369e7b8 | 22 | #include "branch.h" |
5eee6b28 | 23 | #include "parse-options.h" |
d0f379c2 SB |
24 | #include "unpack-trees.h" |
25 | #include "cache-tree.h" | |
35b96d1d SB |
26 | #include "submodule.h" |
27 | #include "submodule-config.h" | |
28 | ||
649bf3a4 BP |
29 | #define REFRESH_INDEX_DELAY_WARNING_IN_MS (2 * 1000) |
30 | ||
5eee6b28 | 31 | static const char * const git_reset_usage[] = { |
c1e9c2a7 | 32 | N_("git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]"), |
d137b507 | 33 | N_("git reset [-q] [<tree-ish>] [--] <pathspec>..."), |
64bac8df | 34 | N_("git reset [-q] [--pathspec-from-file [--pathspec-file-nul]] [<tree-ish>]"), |
d137b507 | 35 | N_("git reset --patch [<tree-ish>] [--] [<pathspec>...]"), |
5eee6b28 CR |
36 | NULL |
37 | }; | |
0e5a7faa | 38 | |
9bc454df CC |
39 | enum reset_type { MIXED, SOFT, HARD, MERGE, KEEP, NONE }; |
40 | static const char *reset_type_names[] = { | |
8b2a57b6 | 41 | N_("mixed"), N_("soft"), N_("hard"), N_("merge"), N_("keep"), NULL |
9bc454df | 42 | }; |
9e8eceab | 43 | |
0e5a7faa CR |
44 | static inline int is_merge(void) |
45 | { | |
102de880 | 46 | return !access(git_path_merge_head(the_repository), F_OK); |
0e5a7faa CR |
47 | } |
48 | ||
3a5d7c55 | 49 | static int reset_index(const struct object_id *oid, int reset_type, int quiet) |
0e5a7faa | 50 | { |
afbb8838 | 51 | int i, nr = 0; |
d0f379c2 | 52 | struct tree_desc desc[2]; |
6c52ec8a | 53 | struct tree *tree; |
d0f379c2 | 54 | struct unpack_trees_options opts; |
afbb8838 | 55 | int ret = -1; |
0e5a7faa | 56 | |
d0f379c2 SB |
57 | memset(&opts, 0, sizeof(opts)); |
58 | opts.head_idx = 1; | |
59 | opts.src_index = &the_index; | |
60 | opts.dst_index = &the_index; | |
61 | opts.fn = oneway_merge; | |
62 | opts.merge = 1; | |
5aa965a0 | 63 | if (!quiet) |
d0f379c2 | 64 | opts.verbose_update = 1; |
9e8eceab | 65 | switch (reset_type) { |
9bc454df | 66 | case KEEP: |
9e8eceab | 67 | case MERGE: |
d0f379c2 | 68 | opts.update = 1; |
9e8eceab LT |
69 | break; |
70 | case HARD: | |
d0f379c2 | 71 | opts.update = 1; |
9e8eceab LT |
72 | /* fallthrough */ |
73 | default: | |
d0f379c2 | 74 | opts.reset = 1; |
9e8eceab | 75 | } |
0e5a7faa | 76 | |
d0f379c2 SB |
77 | read_cache_unmerged(); |
78 | ||
9bc454df | 79 | if (reset_type == KEEP) { |
3a5d7c55 | 80 | struct object_id head_oid; |
81 | if (get_oid("HEAD", &head_oid)) | |
b50a64e8 | 82 | return error(_("You do not have a valid HEAD.")); |
5e575807 | 83 | if (!fill_tree_descriptor(the_repository, desc + nr, &head_oid)) |
b50a64e8 | 84 | return error(_("Failed to find tree of HEAD.")); |
9bc454df CC |
85 | nr++; |
86 | opts.fn = twoway_merge; | |
87 | } | |
88 | ||
5e575807 | 89 | if (!fill_tree_descriptor(the_repository, desc + nr, oid)) { |
afbb8838 JK |
90 | error(_("Failed to find tree of %s."), oid_to_hex(oid)); |
91 | goto out; | |
92 | } | |
e9ce897b JK |
93 | nr++; |
94 | ||
d0f379c2 | 95 | if (unpack_trees(nr, desc, &opts)) |
afbb8838 | 96 | goto out; |
6c52ec8a TR |
97 | |
98 | if (reset_type == MIXED || reset_type == HARD) { | |
a9dbc179 | 99 | tree = parse_tree_indirect(oid); |
c207e9e1 | 100 | prime_cache_tree(the_repository, the_repository->index, tree); |
6c52ec8a TR |
101 | } |
102 | ||
afbb8838 JK |
103 | ret = 0; |
104 | ||
105 | out: | |
106 | for (i = 0; i < nr; i++) | |
107 | free((void *)desc[i].buffer); | |
108 | return ret; | |
0e5a7faa CR |
109 | } |
110 | ||
111 | static void print_new_head_line(struct commit *commit) | |
112 | { | |
1cf823fb | 113 | struct strbuf buf = STRBUF_INIT; |
0e5a7faa | 114 | |
1cf823fb | 115 | printf(_("HEAD is now at %s"), |
aab9583f | 116 | find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV)); |
1cf823fb TG |
117 | |
118 | pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf); | |
119 | if (buf.len > 0) | |
120 | printf(" %s", buf.buf); | |
121 | putchar('\n'); | |
122 | strbuf_release(&buf); | |
0e5a7faa CR |
123 | } |
124 | ||
0e5a7faa CR |
125 | static void update_index_from_diff(struct diff_queue_struct *q, |
126 | struct diff_options *opt, void *data) | |
127 | { | |
128 | int i; | |
b4b313f9 | 129 | int intent_to_add = *(int *)data; |
0e5a7faa CR |
130 | |
131 | for (i = 0; i < q->nr; i++) { | |
132 | struct diff_filespec *one = q->queue[i]->one; | |
a0d12c44 | 133 | int is_missing = !(one->mode && !is_null_oid(&one->oid)); |
b4b313f9 NTND |
134 | struct cache_entry *ce; |
135 | ||
136 | if (is_missing && !intent_to_add) { | |
0e5a7faa | 137 | remove_file_from_cache(one->path); |
b4b313f9 NTND |
138 | continue; |
139 | } | |
140 | ||
a849735b | 141 | ce = make_cache_entry(&the_index, one->mode, &one->oid, one->path, |
b4b313f9 NTND |
142 | 0, 0); |
143 | if (!ce) | |
144 | die(_("make_cache_entry failed for path '%s'"), | |
145 | one->path); | |
146 | if (is_missing) { | |
147 | ce->ce_flags |= CE_INTENT_TO_ADD; | |
148 | set_object_name_for_intent_to_add_entry(ce); | |
149 | } | |
150 | add_cache_entry(ce, ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE); | |
0e5a7faa CR |
151 | } |
152 | } | |
153 | ||
bd1928df | 154 | static int read_from_tree(const struct pathspec *pathspec, |
3a5d7c55 | 155 | struct object_id *tree_oid, |
b4b313f9 | 156 | int intent_to_add) |
0e5a7faa | 157 | { |
0e5a7faa CR |
158 | struct diff_options opt; |
159 | ||
160 | memset(&opt, 0, sizeof(opt)); | |
bd1928df | 161 | copy_pathspec(&opt.pathspec, pathspec); |
0e5a7faa CR |
162 | opt.output_format = DIFF_FORMAT_CALLBACK; |
163 | opt.format_callback = update_index_from_diff; | |
b4b313f9 | 164 | opt.format_callback_data = &intent_to_add; |
0d1e0e78 | 165 | opt.flags.override_submodule_config = 1; |
b78ea5fc | 166 | opt.repo = the_repository; |
0e5a7faa | 167 | |
944cffbd | 168 | if (do_diff_cache(tree_oid, &opt)) |
0e5a7faa CR |
169 | return 1; |
170 | diffcore_std(&opt); | |
171 | diff_flush(&opt); | |
ed6e8038 | 172 | clear_pathspec(&opt.pathspec); |
2e7a9785 | 173 | |
bf883f30 | 174 | return 0; |
0e5a7faa CR |
175 | } |
176 | ||
d04520e3 JK |
177 | static void set_reflog_message(struct strbuf *sb, const char *action, |
178 | const char *rev) | |
0e5a7faa | 179 | { |
0e5a7faa | 180 | const char *rla = getenv("GIT_REFLOG_ACTION"); |
d04520e3 JK |
181 | |
182 | strbuf_reset(sb); | |
183 | if (rla) | |
184 | strbuf_addf(sb, "%s: %s", rla, action); | |
185 | else if (rev) | |
186 | strbuf_addf(sb, "reset: moving to %s", rev); | |
187 | else | |
188 | strbuf_addf(sb, "reset: %s", action); | |
0e5a7faa CR |
189 | } |
190 | ||
812d2a3d CC |
191 | static void die_if_unmerged_cache(int reset_type) |
192 | { | |
2c63d6eb | 193 | if (is_merge() || unmerged_cache()) |
8b2a57b6 ÆAB |
194 | die(_("Cannot do a %s reset in the middle of a merge."), |
195 | _(reset_type_names[reset_type])); | |
812d2a3d CC |
196 | |
197 | } | |
198 | ||
f8144c9f NTND |
199 | static void parse_args(struct pathspec *pathspec, |
200 | const char **argv, const char *prefix, | |
201 | int patch_mode, | |
202 | const char **rev_ret) | |
0e5a7faa | 203 | { |
0e5a7faa | 204 | const char *rev = "HEAD"; |
3a5d7c55 | 205 | struct object_id unused; |
dfc8f39e JH |
206 | /* |
207 | * Possible arguments are: | |
208 | * | |
2f328c3d MZ |
209 | * git reset [-opts] [<rev>] |
210 | * git reset [-opts] <tree> [<paths>...] | |
211 | * git reset [-opts] <tree> -- [<paths>...] | |
212 | * git reset [-opts] -- [<paths>...] | |
dfc8f39e JH |
213 | * git reset [-opts] <paths>... |
214 | * | |
dca48cf5 | 215 | * At this point, argv points immediately after [-opts]. |
dfc8f39e JH |
216 | */ |
217 | ||
dca48cf5 MZ |
218 | if (argv[0]) { |
219 | if (!strcmp(argv[0], "--")) { | |
220 | argv++; /* reset to HEAD, possibly with paths */ | |
221 | } else if (argv[1] && !strcmp(argv[1], "--")) { | |
222 | rev = argv[0]; | |
223 | argv += 2; | |
dfc8f39e JH |
224 | } |
225 | /* | |
dca48cf5 | 226 | * Otherwise, argv[0] could be either <rev> or <paths> and |
2f328c3d MZ |
227 | * has to be unambiguous. If there is a single argument, it |
228 | * can not be a tree | |
dfc8f39e | 229 | */ |
e82caf38 | 230 | else if ((!argv[1] && !get_oid_committish(argv[0], &unused)) || |
231 | (argv[1] && !get_oid_treeish(argv[0], &unused))) { | |
dfc8f39e | 232 | /* |
2f328c3d | 233 | * Ok, argv[0] looks like a commit/tree; it should not |
dfc8f39e JH |
234 | * be a filename. |
235 | */ | |
dca48cf5 MZ |
236 | verify_non_filename(prefix, argv[0]); |
237 | rev = *argv++; | |
dfc8f39e JH |
238 | } else { |
239 | /* Otherwise we treat this as a filename */ | |
dca48cf5 | 240 | verify_filename(prefix, argv[0], 1); |
dfc8f39e JH |
241 | } |
242 | } | |
39ea722d | 243 | *rev_ret = rev; |
2c63d6eb JK |
244 | |
245 | if (read_cache() < 0) | |
246 | die(_("index file corrupt")); | |
247 | ||
480ca644 NTND |
248 | parse_pathspec(pathspec, 0, |
249 | PATHSPEC_PREFER_FULL | | |
250 | (patch_mode ? PATHSPEC_PREFIX_ORIGIN : 0), | |
f8144c9f | 251 | prefix, argv); |
39ea722d MZ |
252 | } |
253 | ||
3a5d7c55 | 254 | static int reset_refs(const char *rev, const struct object_id *oid) |
7bca0e45 MZ |
255 | { |
256 | int update_ref_status; | |
257 | struct strbuf msg = STRBUF_INIT; | |
3a5d7c55 | 258 | struct object_id *orig = NULL, oid_orig, |
259 | *old_orig = NULL, oid_old_orig; | |
7bca0e45 | 260 | |
3a5d7c55 | 261 | if (!get_oid("ORIG_HEAD", &oid_old_orig)) |
262 | old_orig = &oid_old_orig; | |
263 | if (!get_oid("HEAD", &oid_orig)) { | |
264 | orig = &oid_orig; | |
7bca0e45 | 265 | set_reflog_message(&msg, "updating ORIG_HEAD", NULL); |
ae077771 | 266 | update_ref(msg.buf, "ORIG_HEAD", orig, old_orig, 0, |
f4124112 | 267 | UPDATE_REFS_MSG_ON_ERR); |
7bca0e45 | 268 | } else if (old_orig) |
2616a5e5 | 269 | delete_ref(NULL, "ORIG_HEAD", old_orig, 0); |
7bca0e45 | 270 | set_reflog_message(&msg, "updating HEAD", rev); |
ae077771 | 271 | update_ref_status = update_ref(msg.buf, "HEAD", oid, orig, 0, |
f4124112 | 272 | UPDATE_REFS_MSG_ON_ERR); |
7bca0e45 MZ |
273 | strbuf_release(&msg); |
274 | return update_ref_status; | |
275 | } | |
276 | ||
046b4823 SB |
277 | static int git_reset_config(const char *var, const char *value, void *cb) |
278 | { | |
279 | if (!strcmp(var, "submodule.recurse")) | |
280 | return git_default_submodule_config(var, value, cb); | |
281 | ||
282 | return git_default_config(var, value, cb); | |
283 | } | |
284 | ||
39ea722d MZ |
285 | int cmd_reset(int argc, const char **argv, const char *prefix) |
286 | { | |
287 | int reset_type = NONE, update_ref_status = 0, quiet = 0; | |
64bac8df AM |
288 | int patch_mode = 0, pathspec_file_nul = 0, unborn; |
289 | const char *rev, *pathspec_from_file = NULL; | |
f2fd0760 | 290 | struct object_id oid; |
f8144c9f | 291 | struct pathspec pathspec; |
b4b313f9 | 292 | int intent_to_add = 0; |
39ea722d MZ |
293 | const struct option options[] = { |
294 | OPT__QUIET(&quiet, N_("be quiet, only report errors")), | |
295 | OPT_SET_INT(0, "mixed", &reset_type, | |
296 | N_("reset HEAD and index"), MIXED), | |
297 | OPT_SET_INT(0, "soft", &reset_type, N_("reset only HEAD"), SOFT), | |
298 | OPT_SET_INT(0, "hard", &reset_type, | |
299 | N_("reset HEAD, index and working tree"), HARD), | |
300 | OPT_SET_INT(0, "merge", &reset_type, | |
301 | N_("reset HEAD, index and working tree"), MERGE), | |
302 | OPT_SET_INT(0, "keep", &reset_type, | |
303 | N_("reset HEAD but keep local changes"), KEEP), | |
58b75bd6 | 304 | { OPTION_CALLBACK, 0, "recurse-submodules", NULL, |
35b96d1d | 305 | "reset", "control recursive updating of submodules", |
d7a3803f | 306 | PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater }, |
d5d09d47 | 307 | OPT_BOOL('p', "patch", &patch_mode, N_("select hunks interactively")), |
b4b313f9 NTND |
308 | OPT_BOOL('N', "intent-to-add", &intent_to_add, |
309 | N_("record only the fact that removed paths will be added later")), | |
64bac8df AM |
310 | OPT_PATHSPEC_FROM_FILE(&pathspec_from_file), |
311 | OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul), | |
39ea722d MZ |
312 | OPT_END() |
313 | }; | |
314 | ||
046b4823 | 315 | git_config(git_reset_config, NULL); |
4c3abd05 | 316 | git_config_get_bool("reset.quiet", &quiet); |
39ea722d MZ |
317 | |
318 | argc = parse_options(argc, argv, prefix, options, git_reset_usage, | |
319 | PARSE_OPT_KEEP_DASHDASH); | |
f8144c9f | 320 | parse_args(&pathspec, argv, prefix, patch_mode, &rev); |
0e5a7faa | 321 | |
64bac8df AM |
322 | if (pathspec_from_file) { |
323 | if (patch_mode) | |
324 | die(_("--pathspec-from-file is incompatible with --patch")); | |
325 | ||
326 | if (pathspec.nr) | |
327 | die(_("--pathspec-from-file is incompatible with pathspec arguments")); | |
328 | ||
329 | parse_pathspec_file(&pathspec, 0, | |
330 | PATHSPEC_PREFER_FULL, | |
331 | prefix, pathspec_from_file, pathspec_file_nul); | |
332 | } else if (pathspec_file_nul) { | |
333 | die(_("--pathspec-file-nul requires --pathspec-from-file")); | |
334 | } | |
335 | ||
e82caf38 | 336 | unborn = !strcmp(rev, "HEAD") && get_oid("HEAD", &oid); |
166ec2e9 MZ |
337 | if (unborn) { |
338 | /* reset on unborn branch: treat as reset to empty tree */ | |
d8448522 | 339 | oidcpy(&oid, the_hash_algo->empty_tree); |
0a8e3036 | 340 | } else if (!pathspec.nr && !patch_mode) { |
2f328c3d | 341 | struct commit *commit; |
e82caf38 | 342 | if (get_oid_committish(rev, &oid)) |
2f328c3d | 343 | die(_("Failed to resolve '%s' as a valid revision."), rev); |
2122f675 | 344 | commit = lookup_commit_reference(the_repository, &oid); |
2f328c3d MZ |
345 | if (!commit) |
346 | die(_("Could not parse object '%s'."), rev); | |
f2fd0760 | 347 | oidcpy(&oid, &commit->object.oid); |
2f328c3d MZ |
348 | } else { |
349 | struct tree *tree; | |
e82caf38 | 350 | if (get_oid_treeish(rev, &oid)) |
2f328c3d | 351 | die(_("Failed to resolve '%s' as a valid tree."), rev); |
a9dbc179 | 352 | tree = parse_tree_indirect(&oid); |
2f328c3d MZ |
353 | if (!tree) |
354 | die(_("Could not parse object '%s'."), rev); | |
f2fd0760 | 355 | oidcpy(&oid, &tree->object.oid); |
2f328c3d | 356 | } |
0e5a7faa | 357 | |
d002ef4d TR |
358 | if (patch_mode) { |
359 | if (reset_type != NONE) | |
b50a64e8 | 360 | die(_("--patch is incompatible with --{hard,mixed,soft}")); |
c18b6c1a | 361 | trace2_cmd_mode("patch-interactive"); |
b3e9ce13 | 362 | return run_add_interactive(rev, "--patch=reset", &pathspec); |
d002ef4d TR |
363 | } |
364 | ||
0e5a7faa CR |
365 | /* git reset tree [--] paths... can be used to |
366 | * load chosen paths from the tree into the index without | |
367 | * affecting the working tree nor HEAD. */ | |
f8144c9f | 368 | if (pathspec.nr) { |
0e5a7faa | 369 | if (reset_type == MIXED) |
b50a64e8 | 370 | warning(_("--mixed with paths is deprecated; use 'git reset -- <paths>' instead.")); |
0e5a7faa | 371 | else if (reset_type != NONE) |
8b2a57b6 ÆAB |
372 | die(_("Cannot do %s reset with paths."), |
373 | _(reset_type_names[reset_type])); | |
0e5a7faa CR |
374 | } |
375 | if (reset_type == NONE) | |
376 | reset_type = MIXED; /* by default */ | |
377 | ||
c18b6c1a JH |
378 | if (pathspec.nr) |
379 | trace2_cmd_mode("path"); | |
380 | else | |
381 | trace2_cmd_mode(reset_type_names[reset_type]); | |
382 | ||
b7756d41 | 383 | if (reset_type != SOFT && (reset_type != MIXED || get_git_work_tree())) |
cd0f0f68 | 384 | setup_work_tree(); |
49b9362f | 385 | |
2b06b0a0 | 386 | if (reset_type == MIXED && is_bare_repository()) |
8b2a57b6 ÆAB |
387 | die(_("%s reset is not allowed in a bare repository"), |
388 | _(reset_type_names[reset_type])); | |
2b06b0a0 | 389 | |
b4b313f9 NTND |
390 | if (intent_to_add && reset_type != MIXED) |
391 | die(_("-N can only be used with --mixed")); | |
392 | ||
0e5a7faa CR |
393 | /* Soft reset does not touch the index file nor the working tree |
394 | * at all, but requires them in a good order. Other resets reset | |
395 | * the index file to the tree object we are switching to. */ | |
352f58a5 | 396 | if (reset_type == SOFT || reset_type == KEEP) |
812d2a3d | 397 | die_if_unmerged_cache(reset_type); |
352f58a5 MZ |
398 | |
399 | if (reset_type != SOFT) { | |
bfffb48c JK |
400 | struct lock_file lock = LOCK_INIT; |
401 | hold_locked_index(&lock, LOCK_DIE_ON_ERROR); | |
3fde386a | 402 | if (reset_type == MIXED) { |
f38798f4 | 403 | int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN; |
3a5d7c55 | 404 | if (read_from_tree(&pathspec, &oid, intent_to_add)) |
3bbf2f20 | 405 | return 1; |
1956ecd0 | 406 | the_index.updated_skipworktree = 1; |
649bf3a4 BP |
407 | if (!quiet && get_git_work_tree()) { |
408 | uint64_t t_begin, t_delta_in_ms; | |
409 | ||
410 | t_begin = getnanotime(); | |
b7756d41 NTND |
411 | refresh_index(&the_index, flags, NULL, NULL, |
412 | _("Unstaged changes after reset:")); | |
649bf3a4 BP |
413 | t_delta_in_ms = (getnanotime() - t_begin) / 1000000; |
414 | if (advice_reset_quiet_warning && t_delta_in_ms > REFRESH_INDEX_DELAY_WARNING_IN_MS) { | |
415 | printf(_("\nIt took %.2f seconds to enumerate unstaged changes after reset. You can\n" | |
416 | "use '--quiet' to avoid this. Set the config setting reset.quiet to true\n" | |
417 | "to make this the default.\n"), t_delta_in_ms / 1000.0); | |
418 | } | |
419 | } | |
3bbf2f20 | 420 | } else { |
3a5d7c55 | 421 | int err = reset_index(&oid, reset_type, quiet); |
3bbf2f20 | 422 | if (reset_type == KEEP && !err) |
3a5d7c55 | 423 | err = reset_index(&oid, MIXED, quiet); |
3bbf2f20 MZ |
424 | if (err) |
425 | die(_("Could not reset index file to revision '%s'."), rev); | |
426 | } | |
bc41bf42 | 427 | |
bfffb48c | 428 | if (write_locked_index(&the_index, &lock, COMMIT_LOCK)) |
1ca38f85 | 429 | die(_("Could not write new index file.")); |
0e5a7faa | 430 | } |
0e5a7faa | 431 | |
f8144c9f | 432 | if (!pathspec.nr && !unborn) { |
3bbf2f20 MZ |
433 | /* Any resets without paths update HEAD to the head being |
434 | * switched to, saving the previous head in ORIG_HEAD before. */ | |
3a5d7c55 | 435 | update_ref_status = reset_refs(rev, &oid); |
0e5a7faa | 436 | |
3bbf2f20 | 437 | if (reset_type == HARD && !update_ref_status && !quiet) |
2122f675 | 438 | print_new_head_line(lookup_commit_reference(the_repository, &oid)); |
3bbf2f20 | 439 | } |
f8144c9f | 440 | if (!pathspec.nr) |
f4a4b9ac | 441 | remove_branch_state(the_repository, 0); |
0e5a7faa | 442 | |
0e5a7faa CR |
443 | return update_ref_status; |
444 | } |