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

Re: [PATCH] Use git-update-ref in scripts.

From
Linus Torvalds <torvalds@osdl.org>
Date
Sep 29, 2005, 15:16 UTC
Message-ID
<Pine.LNX.4.58.0509290801230.3308@g5.osdl.org>
In-Reply-To
<7vk6h1rr9l.fsf@assigned-by-dhcp.cox.net>
On Wed, 28 Sep 2005, Junio C Hamano wrote:
Show 5 quoted lines
> 
> Hmph.  That sort of makes sense but to make the unconditional
> simple case really fast it should use read-tree -m -u which
> _would_ smudge if things do not go well, which implies you need
> savestate before that which would make it slower -- wouldn't it?
Yeah, we'd have to do something like this.. (untested, surprise, surprise)

NOTE! Even if you don't take this, I noticed what looks like a missing "continue" in the "--head" case. That just can't work without it, afaik.

Not that I know what "--head" is supposed to do.. 
		Linus
---
diff --git a/read-tree.c b/read-tree.c
--- a/read-tree.c
+++ b/read-tree.c
@@ -13,6 +13,8 @@
 static int merge = 0;
 static int update = 0;
 static int index_only = 0;
+static int nontrivial_merge = 0;
+static int trivial_merges_only = 0;
 
 static int head_idx = -1;
 static int merge_size = 0;
@@ -275,6 +277,9 @@ static int unpack_trees(merge_fn_t fn)
 	if (unpack_trees_rec(posns, len, "", fn, &indpos))
 		return -1;
 
+	if (trivial_merges_only && nontrivial_merge)
+		die("Merge requires file-level merging");
+
 	check_updates(active_cache, active_nr);
 	return 0;
 }
@@ -460,6 +465,8 @@ static int threeway_merge(struct cache_e
 		verify_uptodate(index);
 	}
 
+	nontrivial_merge = 1;
+
 	/* #2, #3, #4, #6, #7, #9, #11. */
 	count = 0;
 	if (!head_match || !remote_match) {
@@ -629,9 +636,15 @@ int main(int argc, char **argv)
 			continue;
 		}
 
+		if (!strcmp(arg, "--trivial")) {
+			trivial_merges_only = 1;
+			continue;
+		}
+
 		if (!strcmp(arg, "--head")) {
 			head_idx = stage - 1;
 			fn = threeway_merge;
+			continue;
 		}
 
 		/* "-m" stands for "merge", meaning we start in stage 1 */
Previous: Fredrik KuivinenNext: Junio C Hamano
Message 15 of 19 in “Add "git-update-ref" to update the HEAD (or other) ref”
  1. Linus TorvaldsSep 25, 2005
  2. Linus TorvaldsSep 25, 2005
  3. Junio C HamanoSep 25, 2005
  4. Use git-update-ref in scripts.Junio C Hamano, Sep 28, 2005
  5. Linus TorvaldsSep 28, 2005
  6. Junio C HamanoSep 28, 2005
  7. Linus TorvaldsSep 28, 2005
  8. Junio C HamanoSep 28, 2005
  9. Linus TorvaldsSep 28, 2005
  10. Junio C HamanoSep 28, 2005
  11. Linus TorvaldsSep 29, 2005
  12. Junio C HamanoSep 28, 2005
  13. Junio C HamanoSep 28, 2005
  14. Fredrik KuivinenSep 28, 2005
  15. Linus TorvaldsSep 29, 2005
  16. Junio C HamanoSep 25, 2005
  17. Linus TorvaldsSep 26, 2005
  18. Junio C HamanoSep 26, 2005
  19. Linus TorvaldsSep 26, 2005

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.