Skip to content

Commit 3f921c7

Browse files
pks-tgitster
authored andcommitted
refs: convert MERGE_AUTOSTASH to become a normal pseudo-ref
Similar to the preceding conversion of the AUTO_MERGE pseudo-ref, let's convert the MERGE_AUTOSTASH ref to become a normal pseudo-ref as well. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 35122da commit 3f921c7

File tree

8 files changed

+15
-21
lines changed

8 files changed

+15
-21
lines changed

branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ void remove_merge_branch_state(struct repository *r)
819819
unlink(git_path_merge_mode(r));
820820
refs_delete_ref(get_main_ref_store(r), "", "AUTO_MERGE",
821821
NULL, REF_NO_DEREF);
822-
save_autostash(git_path_merge_autostash(r));
822+
save_autostash_ref(r, "MERGE_AUTOSTASH");
823823
}
824824

825825
void remove_branch_state(struct repository *r, int verbose)

builtin/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1877,7 +1877,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
18771877
&oid, flags);
18781878
}
18791879

1880-
apply_autostash(git_path_merge_autostash(the_repository));
1880+
apply_autostash_ref(the_repository, "MERGE_AUTOSTASH");
18811881

18821882
cleanup:
18831883
strbuf_release(&author_ident);

builtin/merge.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ static void finish(struct commit *head_commit,
476476
run_hooks_l("post-merge", squash ? "1" : "0", NULL);
477477

478478
if (new_head)
479-
apply_autostash(git_path_merge_autostash(the_repository));
479+
apply_autostash_ref(the_repository, "MERGE_AUTOSTASH");
480480
strbuf_release(&reflog_message);
481481
}
482482

@@ -1315,7 +1315,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
13151315
if (abort_current_merge) {
13161316
int nargc = 2;
13171317
const char *nargv[] = {"reset", "--merge", NULL};
1318-
struct strbuf stash_oid = STRBUF_INIT;
1318+
char stash_oid_hex[GIT_MAX_HEXSZ + 1];
1319+
struct object_id stash_oid = {0};
13191320

13201321
if (orig_argc != 2)
13211322
usage_msg_opt(_("--abort expects no arguments"),
@@ -1324,17 +1325,17 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
13241325
if (!file_exists(git_path_merge_head(the_repository)))
13251326
die(_("There is no merge to abort (MERGE_HEAD missing)."));
13261327

1327-
if (read_oneliner(&stash_oid, git_path_merge_autostash(the_repository),
1328-
READ_ONELINER_SKIP_IF_EMPTY))
1329-
unlink(git_path_merge_autostash(the_repository));
1328+
if (!read_ref("MERGE_AUTOSTASH", &stash_oid))
1329+
delete_ref("", "MERGE_AUTOSTASH", &stash_oid, REF_NO_DEREF);
13301330

13311331
/* Invoke 'git reset --merge' */
13321332
ret = cmd_reset(nargc, nargv, prefix);
13331333

1334-
if (stash_oid.len)
1335-
apply_autostash_oid(stash_oid.buf);
1334+
if (!is_null_oid(&stash_oid)) {
1335+
oid_to_hex_r(stash_oid_hex, &stash_oid);
1336+
apply_autostash_oid(stash_oid_hex);
1337+
}
13361338

1337-
strbuf_release(&stash_oid);
13381339
goto done;
13391340
}
13401341

@@ -1563,13 +1564,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
15631564
}
15641565

15651566
if (autostash)
1566-
create_autostash(the_repository,
1567-
git_path_merge_autostash(the_repository));
1567+
create_autostash_ref(the_repository, "MERGE_AUTOSTASH");
15681568
if (checkout_fast_forward(the_repository,
15691569
&head_commit->object.oid,
15701570
&commit->object.oid,
15711571
overwrite_ignore)) {
1572-
apply_autostash(git_path_merge_autostash(the_repository));
1572+
apply_autostash_ref(the_repository, "MERGE_AUTOSTASH");
15731573
ret = 1;
15741574
goto done;
15751575
}
@@ -1655,8 +1655,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
16551655
die_ff_impossible();
16561656

16571657
if (autostash)
1658-
create_autostash(the_repository,
1659-
git_path_merge_autostash(the_repository));
1658+
create_autostash_ref(the_repository, "MERGE_AUTOSTASH");
16601659

16611660
/* We are going to make a new commit. */
16621661
git_committer_info(IDENT_STRICT);
@@ -1741,7 +1740,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
17411740
else
17421741
fprintf(stderr, _("Merge with strategy %s failed.\n"),
17431742
use_strategies[0]->name);
1744-
apply_autostash(git_path_merge_autostash(the_repository));
1743+
apply_autostash_ref(the_repository, "MERGE_AUTOSTASH");
17451744
ret = 2;
17461745
goto done;
17471746
} else if (best_strategy == wt_strategy)

path.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,6 +1588,5 @@ REPO_GIT_PATH_FUNC(merge_msg, "MERGE_MSG")
15881588
REPO_GIT_PATH_FUNC(merge_rr, "MERGE_RR")
15891589
REPO_GIT_PATH_FUNC(merge_mode, "MERGE_MODE")
15901590
REPO_GIT_PATH_FUNC(merge_head, "MERGE_HEAD")
1591-
REPO_GIT_PATH_FUNC(merge_autostash, "MERGE_AUTOSTASH")
15921591
REPO_GIT_PATH_FUNC(fetch_head, "FETCH_HEAD")
15931592
REPO_GIT_PATH_FUNC(shallow, "shallow")

path.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ const char *git_path_merge_msg(struct repository *r);
175175
const char *git_path_merge_rr(struct repository *r);
176176
const char *git_path_merge_mode(struct repository *r);
177177
const char *git_path_merge_head(struct repository *r);
178-
const char *git_path_merge_autostash(struct repository *r);
179178
const char *git_path_fetch_head(struct repository *r);
180179
const char *git_path_shallow(struct repository *r);
181180

refs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1875,7 +1875,6 @@ static int is_special_ref(const char *refname)
18751875
*/
18761876
static const char * const special_refs[] = {
18771877
"FETCH_HEAD",
1878-
"MERGE_AUTOSTASH",
18791878
"MERGE_HEAD",
18801879
};
18811880
size_t i;

repository.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ static void repo_clear_path_cache(struct repo_path_cache *cache)
262262
FREE_AND_NULL(cache->merge_rr);
263263
FREE_AND_NULL(cache->merge_mode);
264264
FREE_AND_NULL(cache->merge_head);
265-
FREE_AND_NULL(cache->merge_autostash);
266265
FREE_AND_NULL(cache->fetch_head);
267266
FREE_AND_NULL(cache->shallow);
268267
}

repository.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ struct repo_path_cache {
6767
char *merge_rr;
6868
char *merge_mode;
6969
char *merge_head;
70-
char *merge_autostash;
7170
char *fetch_head;
7271
char *shallow;
7372
};

0 commit comments

Comments
 (0)