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

[PATCH 2/2] Fix behavior with non-committish upstream references

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
May 11, 2009, 14:42 UTC
Message-ID
<1242052974-28184-3-git-send-email-git@drmicha.warpmail.net>
In-Reply-To
<1242052974-28184-2-git-send-email-git@drmicha.warpmail.net>

stat_tracking_info() assumes that upstream references (as specified by --track or set up automatically) are commits. By calling lookup_commit() on them, create_objects() creates objects for them with type commit no matter what their real type is; this disturbs lookup_tag() later on in the call sequence, leading to git status, git branch -v and git checkout erroring out.

Fix this by using lookup_commit_reference() instead so that (annotated) tags can be used as upstream references.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 remote.c                 |    4 ++--
 t/t6040-tracking-info.sh |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/remote.c b/remote.c
index d66e2f3..2c3e905 100644
--- a/remote.c
+++ b/remote.c
@@ -1399,13 +1399,13 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
 	base = branch->merge[0]->dst;
 	if (!resolve_ref(base, sha1, 1, NULL))
 		return 0;
-	theirs = lookup_commit(sha1);
+	theirs = lookup_commit_reference(sha1);
 	if (!theirs)
 		return 0;
 
 	if (!resolve_ref(branch->refname, sha1, 1, NULL))
 		return 0;
-	ours = lookup_commit(sha1);
+	ours = lookup_commit_reference(sha1);
 	if (!ours)
 		return 0;
 
diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh
index 2397774..e38c597 100755
--- a/t/t6040-tracking-info.sh
+++ b/t/t6040-tracking-info.sh
@@ -82,7 +82,7 @@ test_expect_success 'status when tracking lightweight tags' '
 	git checkout lighttrack
 '
 
-test_expect_failure 'status when tracking annotated tags' '
+test_expect_success 'status when tracking annotated tags' '
 	git checkout master &&
 	git tag -m heavy heavy && 
 	git branch --track heavytrack heavy >actual &&
-- 
1.6.3.195.gad816
Previous: Michael J GruberNext: Michael J Gruber
Message 3 of 4 in “Allow tags as upstreams for --track”
  1. 0/2 Allow tags as upstreams for --trackMichael J Gruber, May 11, 2009
  2. 1/2 Test tracking of non-commit upstreamsMichael J Gruber, May 11, 2009
  3. 2/2 Fix behavior with non-committish upstream referencesMichael J Gruber, May 11, 2009
  4. Michael J GruberMay 14, 2009

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.