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

Re: Commiting automatically (2)

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 19, 2010, 19:32 UTC
Message-ID
<7vaak1ftin.fsf@alter.siamese.dyndns.org>
In-Reply-To
<loom.20101219T090500-396@post.gmane.org>
Maaartin <grajcar1@seznam.cz> writes:
Show 8 quoted lines
> However, when I use my git-autocom script, those files get marked as deleted. 
> This is quite strange, especially because of them still existing. I'd strongly 
> prefer git-autocom to behave just like git commit (i.e., tracking the files).
>
> The relevant part of my script follows:
>
> export GIT_INDEX_FILE=.git/autocom.tmp
> git add -A &&

If you really want "just like commit", then it would be more like "make a commit object out of the current index, and put that somewhere outside the current branch", and will not involve any "git add", no?

A useful goal would be "as if I said 'git add -u && git commit' from the current state" (alternatively, you could say s/-u/-A/).

If this autocom.tmp starts out empty, "add" will of course honor what you wrote in .gitignore hence would not add ignored files. You may have '*.o' in the ignore mechanism to exclude usual build products. Until you somehow tell git that you care about a vendor-supplied binary blob file "binblob1.o" even though it has a name for usual ignored ones, you don't want to get it tracked, and once you have done so with "git add -f", you do want to get it tracked from that point. But your script cannot be clever enough to selectively say "add -f" for such a file.

The "from the current state" part of the sentence of your goal (clarified by the second paragraph above) fundamentally means you need to start from your real index, so "cp -p .git/index $TMP_INDEX" is both appropriate and inevitable for your script.

Previous: MaaartinNext: Maaartin
Message 6 of 13 in “Commiting automatically (2)”
  1. MaaartinDec 19, 2010
  2. Taylor HedbergDec 19, 2010
  3. Jonathan NiederDec 19, 2010
  4. Jonathan NiederDec 19, 2010
  5. MaaartinDec 20, 2010
  6. Junio C HamanoDec 19, 2010
  7. MaaartinDec 20, 2010
  8. Enrico WeigeltDec 20, 2010
  9. MaaartinDec 21, 2010
  10. Jakub NarebskiDec 21, 2010
  11. Jakub NarebskiDec 27, 2010
  12. Maaartin-1Jan 3, 2011
  13. Jakub NarebskiJan 3, 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.