From: "Alex Riesen" <raa.lkml@gmail.com>
To: "Git Mailing List" <git@vger.kernel.org>
Cc: "Junio C Hamano" <junkio@cox.net>
Subject: [PATCH] Fix the remote note the fetch-tool prints after storing a fetched reference
Date: Wed, 6 Jun 2007 17:52:16 +0200 [thread overview]
Message-ID: <81b0412b0706060852y4ab6b794m5fed0484c63159e4@mail.gmail.com> (raw)
In-Reply-To: <81b0412b0706060045k4098eb05tc596214f8d9673bf@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 415 bytes --]
Otherwise ".git" is removed from every remote path which has it,
including "/some/path/somename.git".
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
Fixed truncation of "/.git/" (with a trailing slash).
The old code broke t5515, because it has left "../.git/"
unchanged, but should have removed ".git/".
builtin-fetch--tool.c | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
[-- Attachment #2: 0001-Fix-the-remote-note-the-fetch-tool-prints-after-stori.txt --]
[-- Type: text/plain, Size: 1830 bytes --]
From c767dcc2000c72909013b9e97b18403686b44498 Mon Sep 17 00:00:00 2001
From: Alex Riesen <raa@limbo.localdomain>
Date: Wed, 6 Jun 2007 00:16:14 +0200
Subject: [PATCH] Fix the remote note the fetch-tool prints after storing a fetched reference
Otherwise ".git" is removed from every remote name which has it:
$ git fetch -v
* refs/heads/origin: same as branch 'master' of /home/user/linux
commit: 5ecd310
$ ls /home/user/linux
ls: /home/user/linux: No such file or directory
$ ls /home/user/linux.git
HEAD objects packed-refs ...
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
builtin-fetch--tool.c | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c
index ed4d5de..ec4a8c3 100644
--- a/builtin-fetch--tool.c
+++ b/builtin-fetch--tool.c
@@ -140,7 +140,7 @@ static int append_fetch_head(FILE *fp,
int verbose, int force)
{
struct commit *commit;
- int remote_len, i, note_len;
+ int remote_len, note_len;
unsigned char sha1[20];
char note[1024];
const char *what, *kind;
@@ -173,11 +173,20 @@ static int append_fetch_head(FILE *fp,
}
remote_len = strlen(remote);
- for (i = remote_len - 1; remote[i] == '/' && 0 <= i; i--)
- ;
- remote_len = i + 1;
- if (4 < i && !strncmp(".git", remote + i - 3, 4))
- remote_len = i - 3;
+ if (remote_len > 5) {
+ static const char ending[] = "/.git";
+ const char *pe = ending + 4;
+ const char *pr = remote + remote_len - 1;
+ /* ignore trailing slashes */
+ while (pr > remote && *pr == '/')
+ --pr;
+ for (; pr > remote && pe > ending; --pr, --pe)
+ if (*pr != *pe)
+ break;
+ if (pe == ending)
+ /* "+ 1" to leave the / before .git */
+ remote_len = pr - remote + 1;
+ }
note_len = 0;
if (*what) {
--
1.5.2.1.868.gb85c1
next prev parent reply other threads:[~2007-06-06 15:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-06 7:45 [PATCH] Fix the remote note the fetch-tool prints after storing a fetched reference Alex Riesen
2007-06-06 8:14 ` Junio C Hamano
2007-06-06 8:42 ` Alex Riesen
2007-06-06 8:50 ` J Junio C Hamano
2007-06-06 11:27 ` Alex Riesen
2007-06-06 19:28 ` Junio C Hamano
2007-06-06 15:52 ` Alex Riesen [this message]
2007-06-06 20:07 ` Junio C Hamano
2007-06-06 22:48 ` Alex Riesen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=81b0412b0706060852y4ab6b794m5fed0484c63159e4@mail.gmail.com \
--to=raa.lkml@gmail.com \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).