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

Re: [PATCH/RFC] init, clone: support --real-git-dir for .git file

From
Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
Date
Mar 3, 2011, 21:13 UTC
Message-ID
<4D700469.7090807@gmail.com>
In-Reply-To
<1299156201-12149-1-git-send-email-pclouds@gmail.com>
W dniu 03.03.2011 13:43, Nguyễn Thái Ngọc Duy pisze:
Show 9 quoted lines
> Instead of creating the repository at $GIT_DIR, --real-git-dir will
> tell git to put the repository there, then make $GIT_DIR a .git file
> that points to --real-git-dir.
> 
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  This makes '.git symbolic link' (what's its official name?) more
>  convenient to use. Previously whenever I need to create a .git link,
>  I need to open docs to see its format. Now all I need to do is

Took me a while to find documentation for .git file format. Probably my fault, missed the gitrepository-layout link.

Anyway, tried following:
   $ echo path > .git
   $ git info
   fatal: Invalid gitfile format: .git
Maybe one solution is to improve the message - patch attached:
   $ git info
   fatal: Invalid gitfile format: .git
   Use gitdir: <PATH>
 
Show 9 quoted lines
>   git init --real-git-dir=/where/real/git/is
>   git clone --real-git-dir=/where/real/git/is something
> 
>  I intend to make 'git init --real-git-dir' move current repo to
>  somewhere else if called on existing repo.
> 
>  Long term I'd like to see a init/clone hook, where I can tell git
>  "when I ask you to create a repo/worktree at foo, put the real repo
>  at ~/git/foo"
Is this needed? As I understand
    git init --real-git-dir=/where/real/git/is
should do the same as
    git --git-dir=/where/real/git/is && \
    echo "gitdir: /where/real/git/is" > ${GIT_DIR:-.git} 
The other actions seems to be similarly simple.
>  I could use a better option name too, any suggestions?

I don't understand why is this needed. It's a bit complicated at first as well. Adds extra layer to already existing .gitdir/.gitfile/GIT_DIR/--git-dir

---8<---
From e83caf00dc007b9a2e515bb718f0d9ddb080891e Mon Sep 17 00:00:00 2001
From: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
Date: Thu, 3 Mar 2011 21:51:34 +0100
Subject: [PATCH] Improve error message when gitfile has wrong format
Add information what format of .git file is expected.
Signed-off-by: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
---
 setup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/setup.c b/setup.c
index 021d013..d2d9d0b 100644
--- a/setup.c
+++ b/setup.c
@@ -291,7 +291,7 @@ const char *read_gitfile_gently(const char *path)
 		die("Error reading %s", path);
 	buf[len] = '\0';
 	if (prefixcmp(buf, "gitdir: "))
-		die("Invalid gitfile format: %s", path);
+		die("Invalid gitfile format: %s\nUse gitdir: <PATH>", path);
 	while (buf[len - 1] == '\n' || buf[len - 1] == '\r')
 		len--;
 	if (len < 9)
-- 
1.7.1


-- 
Piotr Krukowiecki
Previous: Nguyễn Thái Ngọc DuyNext: Junio C Hamano
Message 2 of 15 in “init, clone: support --real-git-dir for .git file”
  1. init, clone: support --real-git-dir for .git fileNguyễn Thái Ngọc Duy, Mar 3, 2011
  2. Piotr KrukowieckiMar 3, 2011
  3. Junio C HamanoMar 3, 2011
  4. Piotr KrukowieckiMar 4, 2011
  5. Nguyen Thai Ngoc DuyMar 4, 2011
  6. Piotr KrukowieckiMar 4, 2011
  7. Junio C HamanoMar 4, 2011
  8. Nguyen Thai Ngoc DuyMar 4, 2011
  9. Junio C HamanoMar 4, 2011
  10. Miles BaderMar 4, 2011
  11. Nguyen Thai Ngoc DuyMar 4, 2011
  12. Nguyen Thai Ngoc DuyMar 4, 2011
  13. Junio C HamanoMar 4, 2011
  14. Nguyen Thai Ngoc DuyMar 4, 2011
  15. Miles BaderMar 4, 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.