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

Re: What's cooking in git.git (Aug 2011, #03; Thu, 11)

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 23, 2011, 18:09 UTC
Message-ID
<7vaab0rodu.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4E502302.4000300@ramsay1.demon.co.uk>
Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
> Commit 704c335 (On Cygwin support both UNIX and DOS style path-names,
> 05-08-2011) in pu needs an update to fix the commit message.
Thanks for a reminder, Ramsay.
Here is the exchange where fixing the commit log was mentioned.
    From: Pascal Obry <pascal@obry.net>
    Subject: Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names
    To: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
    Cc: git@vger.kernel.org
    Date: Sat, 13 Aug 2011 19:34:37 +0200
    Message-ID: <4E46B5AD.5050806@obry.net>
    Le 11/08/2011 22:35, Ramsay Jones a écrit :
    >   ... could you please correct your commit message. Thanks!
    Done, thanks for your review.
> Also, I didn't see any response to Johannes Sixt's query concerning
> backslash in pathspec. (I personally don't want to go down that
> route, but ...)
Here is what J6t said in the message:
  From: Johannes Sixt <j6t@kdbg.org>
  Subject: Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names
  Date: Tue, 09 Aug 2011 21:47:15 +0200
  Message-ID: <4E418EC3.4070904@kdbg.org>
  > Do you also want to support this:
  >      $ git add src\file.c
  > i.e., backslash in pathspec? Then you need more than this:
  > > +#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
  > > +#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
  >
  > In particular, you have to enable backslash processing in
  > setup.c:prefix_filename(), but then you lose the ability to escape
  > special characters with the backslash.

When "git add src\file.c" is given from the command line, what does our main() see in argv[2]? Do cmd.exe and bash give us the same thing? What if the command line is "git add 'src\*.c'"?

I vaguely recall that on Windows you only get a single parameter string from the program loader, and arguments are split in the invoked process, but that is so common that as far as our main() is concerned we can expect the example command line to give us argc=3 and argv={ "git", "add", "???", NULL }. What I do not recall is if there is some other magic such as expanding shell globs and swapping the direction of slashes in strings involved when this argument processing is done.

You probably _could_ do '\\' -> '/' inside prefix_filename() and get_pathspec(), but as J6t mentioned, we _do_ handle backslash as a quoting character, and this is _not_ going to change.

So even if we were to go that route, the user would need to make git see "src\\file.c" or "src\\*.c" in order to make it turn into "src/file.c" and "src/*.c" pathspec. If it means that the user needs to type:

	$ git add src\\\\file.c
I would have to say that it would be simpler for them to say
	$ git add src/file.c

even on Cygwin. After all, isn't Cygwin for people who are forced to be on Windows and miss POSIXy environments?

By the way, Johannes, how does Git for Windows handle pathspecs?
Previous: Ramsay JonesNext: Johannes Sixt
Message 10 of 12 in “What's cooking in git.git (Aug 2011, #03; Thu, 11)”
  1. Junio C HamanoAug 11, 2011
  2. Philip OakleyAug 13, 2011
  3. Junio C HamanoAug 16, 2011
  4. Ramkumar RamachandraAug 14, 2011
  5. Junio C HamanoAug 16, 2011
  6. Ramkumar RamachandraAug 18, 2011
  7. Pascal ObryAug 18, 2011
  8. Junio C HamanoAug 18, 2011
  9. Ramsay JonesAug 20, 2011
  10. Junio C HamanoAug 23, 2011
  11. Johannes SixtAug 24, 2011
  12. Pascal ObryAug 21, 2011

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.