Re: [PATCH 2/2] Improve the naming of guessed target repository for git clone
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 14, 2009, 00:41 UTC
- Message-ID
- <7vfxf81ppd.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <20090513205333.GA21631@blimp.localdomain>
Alex Riesen <raa.lkml@gmail.com> writes:
Show 12 quoted lines
> Strip trailing spaces off guessed target directory in builtin clone, > and replace 'control' characters with an ASCII space. > > User still can have any name by specifying it explicitely after url. > > Signed-off-by: Alex Riesen <raa.lkml@gmail.com> > --- > > This should take care of accidental pastings inside shell quotes. > At least for the local part of the operation. > Now I'm looking at the code and think I should have stripped the > heading whitespace as well. It is much less likely to happen, though.
Show 11 quoted lines
> @@ -140,10 +141,21 @@ static char *guess_dir_name(const char *repo, int is_bundle, int is_bare)
> if (is_bare) {
> struct strbuf result = STRBUF_INIT;
> strbuf_addf(&result, "%.*s.git", (int)(end - start), start);
> + dir = strbuf_detach(&result, 0);
> + } else
> + dir = xstrndup(start, end - start);
> + /* replace all 'control' characters with ascii space */
> + for (start = dir; *start; ++start)
> + if (*(const unsigned char *)start < 32u)
> + dir[start - dir] = '\x20';What's this strange mixture of 32u and '\x20'?
Show 9 quoted lines
> + /* remove trailing spaces */ > + if (dir < start) > + for (end = start; dir < --end; ) > + if (!isspace(*end)) > + break; > + else > + dir[end - dir] = '\0'; > + return dir; > }
Honestly, I regret having asked if there was a 2/2 ;-)
What's the point of this change, now that you have a fix in 1/2? Who are you helping with this patch?