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

[PATCH] Fix overwritten remote ref on with fast-import.

From
Florian Achleitner <florian.achleitner.2.6.31@gmail.com>
Date
Jul 15, 2012, 14:26 UTC
Message-ID
<1342362383-31167-1-git-send-email-florian.achleitner.2.6.31@gmail.com>
In-Reply-To
<1342013933-14381-1-git-send-email-florian.achleitner.2.6.31@gmail.com>

After importing new commits on top of refs/remotes/* the ref was overwritten with the local refs/heads/master, because the name of the remote reference to fetch, i.e. refs/heads/master, was used to retrieve old_sha1 for it's local counterpart. Therefore, old_sha1 pointed to the local head which was not contained in the remote branch and couldn't be updated (printing a warning ..).

There are some points that are still not completely clear to me:
- I found, that the remote ref I need is stored in ref->peer_ref. There
  is one little comment on peer_ref saying /* when renaming */. That doesn't say much
  to me. Is peer_ref the correct solution?
- fast-import's commit command does already add a commit to a branch. The
  remote ref was already correct, but got overwritten by store_updated_refs
  after fast import terminated. (I figured that out using strace).
  So the update is somewhat redundant. But probably only in this special case.(?)
Signed-off-by: Florian Achleitner <florian.achleitner.2.6.31@gmail.com>
---
 transport-helper.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/transport-helper.c b/transport-helper.c
index d6daad5..a0f05ce 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -485,8 +485,10 @@ static int fetch_with_import(struct transport *transport,
 			continue;
 		if (data->refspecs)
 			private = apply_refspecs(data->refspecs, data->refspec_nr, posn->name);
+		else if (posn->peer_ref)
+			private = xstrdup(posn->peer_ref->name);
 		else
-			private = xstrdup(posn->name);
+			private = NULL;
 		if (private) {
 			read_ref(private, posn->old_sha1);
 			free(private);
-- 
1.7.9.5
Previous: Stephen BashNext: Jonathan Nieder
Message 9 of 20 in “GSOC remote-svn”
  1. 0/4 GSOC remote-svnFlorian Achleitner, Jul 11, 2012
  2. 1/4 vcs-svn: add fast_export_note to create notesFlorian Achleitner, Jul 11, 2012
  3. 2/4 Allow reading svn dumps from files via file:// urls.Florian Achleitner, Jul 11, 2012
  4. 3/4 Create a note for every imported commit containing svn metadata.Florian Achleitner, Jul 11, 2012
  5. 4/4 When debug==1, start fast-import with "--stats" instead of "--quiet".Florian Achleitner, Jul 11, 2012
  6. Dmitry IvankovJul 11, 2012
  7. Junio C HamanoJul 11, 2012
  8. Stephen BashJul 11, 2012
  9. Fix overwritten remote ref on with fast-import.Florian Achleitner, Jul 15, 2012
  10. Jonathan NiederJul 16, 2012
  11. Junio C HamanoJul 16, 2012
  12. Florian AchleitnerJul 16, 2012
  13. Jonathan NiederJul 17, 2012
  14. Florian AchleitnerJul 17, 2012
  15. Jonathan NiederJul 17, 2012
  16. Florian AchleitnerJul 17, 2012
  17. Jonathan NiederJul 17, 2012
  18. Florian AchleitnerJul 17, 2012
  19. Add explanatory comment for transport-helpers refs mapping.Florian Achleitner, Jul 17, 2012
  20. Jonathan NiederJul 17, 2012

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.