Elijah Newren via GitGitGadget <gitgitgadget@xxxxxxxxx> 于2022年6月19日周日 14:50写道: > > From: Elijah Newren <newren@xxxxxxxxx> > > When there are racy-dirty files, but no files are modified, > `git stash create` exits with unsuccessful status. This causes merge > to fail. Refresh the index first to avoid this problem. > > Signed-off-by: Elijah Newren <newren@xxxxxxxxx> > --- > builtin/merge.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/builtin/merge.c b/builtin/merge.c > index 00de224a2da..8ce4336dd3f 100644 > --- a/builtin/merge.c > +++ b/builtin/merge.c > @@ -313,8 +313,16 @@ static int save_state(struct object_id *stash) > int len; > struct child_process cp = CHILD_PROCESS_INIT; > struct strbuf buffer = STRBUF_INIT; > + struct lock_file lock_file = LOCK_INIT; > + int fd; > int rc = -1; > > + fd = repo_hold_locked_index(the_repository, &lock_file, 0); > + refresh_cache(REFRESH_QUIET); > + if (0 <= fd) > + repo_update_index_if_able(the_repository, &lock_file); > + rollback_lock_file(&lock_file); > + > strvec_pushl(&cp.args, "stash", "create", NULL); > cp.out = -1; > cp.git_cmd = 1; > -- > gitgitgadget > I just want to show what sence will meet this errors: 1. touch file 2. git add file 3. git stash push (user may do it before git merge) 4. touch file (update file but not update its content) 5. git merge (call git stash create and return 1) So I have knew about what's the meaning of this patch: If user do the git stash manually and update file timestamp before git merge, it may make next git stash failed. And refresh index can make index entry sync with the work tree file status. Thanks. ZheNing Hu