<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/sequencer.c, branch gitk-resize-error</title>
<subtitle>Fork of git SCM with my patches.</subtitle>
<id>http://git.kilabit.info/git/atom?h=gitk-resize-error</id>
<link rel='self' href='http://git.kilabit.info/git/atom?h=gitk-resize-error'/>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/'/>
<updated>2022-01-29T00:45:52Z</updated>
<entry>
<title>Merge branch 'en/keep-cwd' into maint</title>
<updated>2022-01-29T00:45:52Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-01-29T00:45:39Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=f120b65cd41c0e93432af1a36c82fd3a8d39ccd4'/>
<id>urn:sha1:f120b65cd41c0e93432af1a36c82fd3a8d39ccd4</id>
<content type='text'>
Fix a regression in 2.35 that roke the use of "rebase" and "stash"
in a secondary worktree.

* en/keep-cwd:
  sequencer, stash: fix running from worktree subdir
</content>
</entry>
<entry>
<title>sequencer, stash: fix running from worktree subdir</title>
<updated>2022-01-26T20:01:54Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2022-01-26T01:43:45Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=ff5b7913f0af62c26682b0376d0aa2d7f5d74b2e'/>
<id>urn:sha1:ff5b7913f0af62c26682b0376d0aa2d7f5d74b2e</id>
<content type='text'>
In commits bc3ae46b42 ("rebase: do not attempt to remove
startup_info-&gt;original_cwd", 2021-12-09) and 0fce211ccc ("stash: do not
attempt to remove startup_info-&gt;original_cwd", 2021-12-09), we wanted to
allow the subprocess to know which directory the parent process was
running from, so that the subprocess could protect it.  However...

When run from a non-main worktree, setup_git_directory() will note
that the discovered git directory
(/PATH/TO/.git/worktree/non-main-worktree) does not match
DEFAULT_GIT_DIR_ENVIRONMENT (see setup_discovered_git_dir()), and
decide to set GIT_DIR in the environment.  This matters because...

Whenever git is run with the GIT_DIR environment variable set, and
GIT_WORK_TREE not set, it presumes that '.' is the working tree.  So...

This combination results in the subcommand being very confused about
the working tree.  Fix it by also setting the GIT_WORK_TREE environment
variable along with setting cmd.dir.

A possibly more involved fix we could consider for later would be to
make setup.c set GIT_WORK_TREE whenever (a) it discovers both the git
directory and the working tree and (b) it decides to set GIT_DIR in the
environment.  I did not attempt that here as such would be too big of a
change for a 2.35.1 release.

Test-case-by: Glen Choo &lt;chooglen@google.com&gt;
Signed-off-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'en/keep-cwd'</title>
<updated>2022-01-05T22:01:28Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-01-05T22:01:28Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=da81d473fcfa67dfbcf0504d2b5225885e51e532'/>
<id>urn:sha1:da81d473fcfa67dfbcf0504d2b5225885e51e532</id>
<content type='text'>
Many git commands that deal with working tree files try to remove a
directory that becomes empty (i.e. "git switch" from a branch that
has the directory to another branch that does not would attempt
remove all files in the directory and the directory itself).  This
drops users into an unfamiliar situation if the command was run in
a subdirectory that becomes subject to removal due to the command.
The commands have been taught to keep an empty directory if it is
the directory they were started in to avoid surprising users.

* en/keep-cwd:
  t2501: simplify the tests since we can now assume desired behavior
  dir: new flag to remove_dir_recurse() to spare the original_cwd
  dir: avoid incidentally removing the original_cwd in remove_path()
  stash: do not attempt to remove startup_info-&gt;original_cwd
  rebase: do not attempt to remove startup_info-&gt;original_cwd
  clean: do not attempt to remove startup_info-&gt;original_cwd
  symlinks: do not include startup_info-&gt;original_cwd in dir removal
  unpack-trees: add special cwd handling
  unpack-trees: refuse to remove startup_info-&gt;original_cwd
  setup: introduce startup_info-&gt;original_cwd
  t2501: add various tests for removing the current working directory
</content>
</entry>
<entry>
<title>Merge branch 'en/rebase-x-wo-git-dir-env'</title>
<updated>2021-12-21T23:03:15Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-12-21T23:03:15Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=57f28f40943c077ef1dc11c693d693b1bd6b7f2f'/>
<id>urn:sha1:57f28f40943c077ef1dc11c693d693b1bd6b7f2f</id>
<content type='text'>
"git rebase -x" by mistake started exporting the GIT_DIR and
GIT_WORK_TREE environment variables when the command was rewritten
in C, which has been corrected.

* en/rebase-x-wo-git-dir-env:
  sequencer: do not export GIT_DIR and GIT_WORK_TREE for 'exec'
</content>
</entry>
<entry>
<title>Merge branch 'ab/run-command'</title>
<updated>2021-12-15T17:39:47Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-12-15T17:39:47Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=832ec72c3e15820c3b728b3a56398655d7bb7cb3'/>
<id>urn:sha1:832ec72c3e15820c3b728b3a56398655d7bb7cb3</id>
<content type='text'>
API clean-up.

* ab/run-command:
  run-command API: remove "env" member, always use "env_array"
  difftool: use "env_array" to simplify memory management
  run-command API: remove "argv" member, always use "args"
  run-command API users: use strvec_push(), not argv construction
  run-command API users: use strvec_pushl(), not argv construction
  run-command tests: use strvec_pushv(), not argv assignment
  run-command API users: use strvec_pushv(), not argv assignment
  upload-archive: use regular "struct child_process" pattern
  worktree: stop being overly intimate with run_command() internals
</content>
</entry>
<entry>
<title>Merge branch 'en/rebase-x-fix'</title>
<updated>2021-12-10T22:35:16Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-12-10T22:35:16Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=3e1dbfa135cf131281aa92f159073dc892bac419'/>
<id>urn:sha1:3e1dbfa135cf131281aa92f159073dc892bac419</id>
<content type='text'>
"git rebase -x" added an unnecessary 'exec' instructions before
'noop', which has been corrected.

* en/rebase-x-fix:
  sequencer: avoid adding exec commands for non-commit creating commands
</content>
</entry>
<entry>
<title>rebase: do not attempt to remove startup_info-&gt;original_cwd</title>
<updated>2021-12-09T21:33:13Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2021-12-09T05:08:31Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=bc3ae46b420f58dfe2bfd87714dca096a043d554'/>
<id>urn:sha1:bc3ae46b420f58dfe2bfd87714dca096a043d554</id>
<content type='text'>
Since rebase spawns a `checkout` subprocess, make sure we run that from
the startup_info-&gt;original_cwd directory, so that the checkout process
knows to protect that directory.

Acked-by: Derrick Stolee &lt;stolee@gmail.com&gt;
Acked-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>sequencer: do not export GIT_DIR and GIT_WORK_TREE for 'exec'</title>
<updated>2021-12-05T07:41:05Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2021-12-04T05:36:59Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=434e0636db102cd89292ea28e8e947fa6e790b23'/>
<id>urn:sha1:434e0636db102cd89292ea28e8e947fa6e790b23</id>
<content type='text'>
Commands executed from `git rebase --exec` can give different behavior
from within that environment than they would outside of it, due to the
fact that sequencer.c exports both GIT_DIR and GIT_WORK_TREE.  For
example, if the relevant script calls something like

  git -C ../otherdir log --format=%H --no-walk

the user may be surprised to find that the command above does not show a
commit hash from ../otherdir, because $GIT_DIR prevents automatic gitdir
detection and makes the -C option useless.

This is a regression in behavior from the original legacy
implemented-in-shell rebase.  It is perhaps rare for it to cause
problems in practice, especially since most small problems that were
caused by this area of bugs has been fixed-up in the past in a way that
masked the particular bug observed without fixing the real underlying
problem.

An explanation of how we arrived at the current situation is perhaps
merited.  The setting of GIT_DIR and GIT_WORK_TREE done by sequencer.c
arose from a sequence of historical accidents:

* When rebase was implemented as a shell command, it would call
  git-sh-setup, which among other things would set GIT_DIR -- but not
  export it.  This meant that when rebase --exec commands were run via
      /bin/sh -c "$COMMAND"
  they would not inherit the GIT_DIR setting.  The fact that GIT_DIR
  was not set in the run $COMMAND is the behavior we'd like to restore.

* When the rebase--helper builtin was introduced to allow incrementally
  replacing shell with C code, we had an implementation that was half
  shell, half C.  In particular, commit 18633e1a22 ("rebase -i: use the
  rebase--helper builtin", 2017-02-09) added calls to
      exec git rebase--helper ...
  which caused rebase--helper to inherit the GIT_DIR environment
  variable from the shell.  git's setup would change the environment
  variable from an absolute path to a relative one (".git"), but would
  leave it set.  This meant that when rebase --exec commands were run
  via
      run_command_v_opt(...)
  they would inherit the GIT_DIR setting.

* In commit 09d7b6c6fa ("sequencer: pass absolute GIT_DIR to exec
  commands", 2017-10-31), it was noted that the GIT_DIR caused problems
  with some commands; e.g.
      git rebase --exec 'cd subdir &amp;&amp; git describe' ...
  would have GIT_DIR=.git which was invalid due to the change to the
  subdirectory.  Instead of questioning why GIT_DIR was set, that commit
  instead made sequencer change GIT_DIR to be an absolute path and
  explicitly export it via
      argv_array_pushf(&amp;child_env, "GIT_DIR=%s", absolute_path(get_git_dir()));
      run_command_v_opt_cd_env(..., child_env.argv)

* In commit ab5e67d751 ("sequencer: pass absolute GIT_WORK_TREE to exec
  commands", 2018-07-14), it was noted that when GIT_DIR is set but
  GIT_WORK_TREE is not, that we do not discover GIT_WORK_TREE but just
  assume it is '.'.  That is incorrect if trying to run commands from a
  subdirectory.  However, rather than question why GIT_DIR was set, that
  commit instead also added GIT_WORK_TREE to the list of things to
  export.

Each of the above problems would have been fixed automatically when
git-rebase became a full builtin, had it not been for the fact that
sequencer.c started exporting GIT_DIR and GIT_WORK_TREE in the interim.
Stop exporting them now.

Signed-off-by: Elijah Newren &lt;newren@gmail.com&gt;
Acked-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Acked-by: Johannes Altmanninger &lt;aclopte@gmail.com&gt;
Acked-by: Phillip Wood &lt;phillip.wood123@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>sequencer: avoid adding exec commands for non-commit creating commands</title>
<updated>2021-11-30T06:53:26Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2021-11-30T03:58:39Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=cc9dcdee6142d39cdd42d23b81d2a256f591d289'/>
<id>urn:sha1:cc9dcdee6142d39cdd42d23b81d2a256f591d289</id>
<content type='text'>
The `--exec &lt;cmd&gt;` is documented as

    Append "exec &lt;cmd&gt;" after each line creating a commit in the final
    history.
    ...
    If --autosquash is used, "exec" lines will not be appended for the
    intermediate commits, and will only appear at the end of each
    squash/fixup series.

Unfortunately, it would also add exec commands after non-pick
operations, such as 'no-op', which could be seen for example with
    git rebase -i --exec true HEAD

todo_list_add_exec_commands() intent was to insert exec commands after
each logical pick, while trying to consider a chains of fixup and squash
commits to be part of the pick before it.  So it would keep an 'insert'
boolean tracking if it had seen a pick or merge, but not write the exec
command until it saw the next non-fixup/squash command.  Since that
would make it miss the final exec command, it had some code that would
check whether it still needed to insert one at the end, but instead of a
simple

    if (insert)

it had a

    if (insert || &lt;condition that is always true&gt;)

That's buggy; as per the docs, we should only add exec commands for
lines that create commits, i.e. only if insert is true.  Fix the
conditional.

There was one testcase in the testsuite that we tweak for this change;
it was introduced in 54fd3243da ("rebase -i: reread the todo list if
`exec` touched it", 2017-04-26), and was merely testing that after an
exec had fired that the todo list would be re-read.  The test at the
time would have worked given any revision at all, though it would only
work with 'HEAD' as a side-effect of this bug.  Since we're fixing this
bug, choose something other than 'HEAD' for that test.

Finally, add a testcase that verifies when we have no commits to pick,
that we get no exec lines in the generated todo list.

Reported-by: Nikita Bobko &lt;nikitabobko@gmail.com&gt;
Signed-off-by: Elijah Newren &lt;newren@gmail.com&gt;
Acked-by: Taylor Blau &lt;me@ttaylorr.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ab/refs-errno-cleanup'</title>
<updated>2021-11-29T23:41:45Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-11-29T23:41:45Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=96f6623ada056c24a60e10ad58acc42871dd9f41'/>
<id>urn:sha1:96f6623ada056c24a60e10ad58acc42871dd9f41</id>
<content type='text'>
The "remainder" of hn/refs-errno-cleanup topic.

* ab/refs-errno-cleanup: (21 commits)
  refs API: post-migration API renaming [2/2]
  refs API: post-migration API renaming [1/2]
  refs API: don't expose "errno" in run_transaction_hook()
  refs API: make expand_ref() &amp; repo_dwim_log() not set errno
  refs API: make resolve_ref_unsafe() not set errno
  refs API: make refs_ref_exists() not set errno
  refs API: make refs_resolve_refdup() not set errno
  refs tests: ignore ignore errno in test-ref-store helper
  refs API: ignore errno in worktree.c's find_shared_symref()
  refs API: ignore errno in worktree.c's add_head_info()
  refs API: make files_copy_or_rename_ref() et al not set errno
  refs API: make loose_fill_ref_dir() not set errno
  refs API: make resolve_gitlink_ref() not set errno
  refs API: remove refs_read_ref_full() wrapper
  refs/files: remove "name exist?" check in lock_ref_oid_basic()
  reflog tests: add --updateref tests
  refs API: make refs_rename_ref_available() static
  refs API: make parse_loose_ref_contents() not set errno
  refs API: make refs_read_raw_ref() not set errno
  refs API: add a version of refs_resolve_ref_unsafe() with "errno"
  ...
</content>
</entry>
</feed>
