git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Why is "Sparse checkout leaves no entry on working directory" a fatal error?
@ 2019-10-08  6:45 Josef Wolf
  2019-10-08 16:14 ` Elijah Newren
  0 siblings, 1 reply; 3+ messages in thread
From: Josef Wolf @ 2019-10-08  6:45 UTC (permalink / raw)
  To: git

Hello,

This is a repost, since the original message seems to have been lost somehow.


I am trying to add a file to an arbitrary branch without touching the current
worktree with as little overhead as possible. This should work no matter in
which state the current worktree is in. And it should not touch the current WT
in any way.

For this, the sparse-checkout feature in conjuntion with the "shared
repository" feature seems to be perfect.

The basic idea goes like this:


   TMP=`mktemp -d /var/tmp/test-XXXXXXXXX`
   GD=$TMP/git
   WD=$TMP/wd
   
   git --work-tree $WD --git-dir $GD clone -qns -n . $GD
   git --work-tree $WD --git-dir $GD config core.sparsecheckout true
   echo path/of/file/which/I/want/to/create >>$GD/info/sparse-checkout
   
   git --work-tree $WD --git-dir $GD checkout -b some-branch remotes/origin/some-branch  # !!!
   
   ( cd $WD
     mkdir -p path/of/file/which/I/want/to
     echo huhuh >path/of/file/which/I/want/to/create
     git --work-tree $WD --git-dir $GD add path/of/file/which/I/want/to/create
     git --work-tree $WD --git-dir $GD commit
     git --work-tree $WD --git-dir $GD push
   )
   
   rm -rf $TMP


Unfortunately, the marked command errors out with

   "error: Sparse checkout leaves no entry on working directory"

and won't create/switch to the branch that is to be modified.

Why is this an error? Since there are no matching files, an empty worktree
is EXACTLY what I wanted. Why will the "git checkout -b" command error out?


Strange enough, I have some repositories at this machine where the
.git/info/sparse-checkout file contains only non-existing files and git
happily executes this "git checkout -b XXX remotes/origin/XXX" command leaving
the working tree totally empty all the time.

Someone understands this inconsistent behaviour?

Thanks,

-- 
Josef Wolf
jw@raven.inka.de

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-09  9:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-08  6:45 Why is "Sparse checkout leaves no entry on working directory" a fatal error? Josef Wolf
2019-10-08 16:14 ` Elijah Newren
2019-10-09  9:37   ` Josef Wolf

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).