git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Okay to invoke merge-recursive with an empty workdir?

From
Jay Soffian <jaysoffian@gmail.com>
Date
Sep 13, 2011, 03:13 UTC
Message-ID
<CAG+J_Dyz-aeLYn43ARTG4GJz0+zRw_RyDr80bmPCayd9BjzCwg@mail.gmail.com>

I have an unattended script which performs automated merges into several destination branches.

As the repo is fairly large, I'd like not to have to checkout each destination branch, nor have multiple workdirs.

So my approach is to create a temporary, empty, workdir, using symlinks to point to the parent repo per git new-workdir.

I then invoke merge-recursive directly inside the temporary workdir.

The question is whether this is safe to do, or whether merge-recursive expects a fully populated working tree that matches the index. My easy test cases seem to work correctly, but I'm concerned that I sometimes get:

Skipped /some/file (merged same as existing) error: addinfo_cache failed for path '/some/file' Skipped some/other_file (merged same as existing) error: addinfo_cache failed for path 'some/other_file'

Which seems to be from this code in merge-recursive.cc:
	if (mfi.clean && !df_conflict_remains &&
	    sha_eq(mfi.sha, a_sha) && mfi.mode == a_mode) {
		int path_renamed_outside_HEAD;
		output(o, 3, "Skipped %s (merged same as existing)", path);
		/*
		 * The content merge resulted in the same file contents we
		 * already had.  We can return early if those file contents
		 * are recorded at the correct path (which may not be true
		 * if the merge involves a rename).
		 */
		path_renamed_outside_HEAD = !path2 || !strcmp(path, path2);
		if (!path_renamed_outside_HEAD) {
			add_cacheinfo(mfi.mode, mfi.sha, path,
				      0 /*stage*/, 1 /*refresh*/, 0 /*options*/);
			return mfi.clean;
		}

(Peff, hope you don't mind me cc'ing you directly. I seem to recall you're saying github is doing something like this but I couldn't find that email.)

j.
Next: Jeff King
Message 1 of 4 in “Okay to invoke merge-recursive with an empty workdir?”
  1. Jay SoffianSep 13, 2011
  2. Jeff KingSep 13, 2011
  3. Junio C HamanoSep 13, 2011
  4. Jeff KingSep 13, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.