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

Re: [PATCH] stash: copy the index using --index-output instead of cp -p

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Mar 15, 2011, 19:53 UTC
Message-ID
<AANLkTi=+-tDz6XSSUAyvzGZ6fJohSU+rY4GhRa5C-+oA@mail.gmail.com>
In-Reply-To
<7vk4g09o9x.fsf@alter.siamese.dyndns.org>
On Tue, Mar 15, 2011 at 20:28, Junio C Hamano <gitster@pobox.com> wrote:
Show 7 quoted lines
> Johannes Sixt <j.sixt@viscovery.net> writes:
>
>> Luckily, the first operation in git-stash after copying the index is to
>> call 'git read-tree'. Therefore, use --index-output instead of 'cp -p'
>> to write the copy of the index.
>
> Thanks, will apply.

Please note that the file to the --index-output option needs to be on the same filesystem as GIT_INDEX_FILE, so that it can be renamed. Here is the corresponding manual page paragraph for this:

       --index-output=<file>
           Instead of writing the results out to $GIT_INDEX_FILE, write the
           resulting index in the named file. While the command is operating,
           the original index file is locked with the same mechanism as usual.
           The file must allow to be rename(2)ed into from a temporary file
           that is created next to the usual index file; typically this means
           it needs to be on the same filesystem as the index file itself, and
           you need write permission to the directories the index file and
           index output file are located in.

I don' have the full context, so I can't judge whether $TMP-index is guaranteed to be on the same filesystem as ${GIT_INDEX_FILE-"$GIT_DIR/index"}.

Bert
Previous: Junio C HamanoNext: Johannes Sixt
Message 6 of 9 in “[RFD] git stash over OpenBSD/Linux NFS - cp -p breakage”
  1. Jakob PfenderMar 15, 2011
  2. Johannes SixtMar 15, 2011
  3. Jakob PfenderMar 15, 2011
  4. stash: copy the index using --index-output instead of cp -pJohannes Sixt, Mar 15, 2011
  5. Junio C HamanoMar 15, 2011
  6. Bert WesargMar 15, 2011
  7. Johannes SixtMar 16, 2011
  8. 1/2 stash: fix incorrect quoting in cleanup of temporary filesJohannes Sixt, Mar 16, 2011
  9. 2/2 stash: copy the index using --index-output instead of cp -pJohannes Sixt, Mar 16, 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.