Re: [PATCH v3 9/9] bugreport: print contents of alternates file
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Oct 28, 2019, 15:57 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1910281655420.46@tvgsbejvaqbjf.bet>
- In-Reply-To
- <20191025025129.250049-10-emilyshaffer@google.com>
Hi Emily,
On Thu, 24 Oct 2019, Emily Shaffer wrote:
> In some cases, it could be that the user is having a problem with an > object which isn't present in their normal object directory. We can get > a hint that that might be the case by examining the list of alternates > where their object may be stored instead.
Doesn't this open the possibility of leaking project's (possibly NDA'ed) names?
I could imagine that we might rather want to count the alternates, and maybe separate into those alternates that actually exist and alternates that do not exist (which would produce a warning that the user might have trained themselves to ignore).
Ciao, Dscho
Show 63 quoted lines
>
> Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
> ---
> bugreport.c | 14 ++++++++++++++
> bugreport.h | 6 ++++++
> builtin/bugreport.c | 4 ++++
> 3 files changed, 24 insertions(+)
>
> diff --git a/bugreport.c b/bugreport.c
> index ce15904fec..a7bdc72b7f 100644
> --- a/bugreport.c
> +++ b/bugreport.c
> @@ -298,3 +298,17 @@ void get_object_info_summary(struct strbuf *obj_info)
> strbuf_complete_line(obj_info);
> }
> }
> +
> +void get_alternates_file(struct strbuf *alternates_info)
> +{
> + struct strbuf alternates_path = STRBUF_INIT;
> +
> + strbuf_addstr(&alternates_path, get_object_directory());
> + strbuf_complete(&alternates_path, '/');
> + strbuf_addstr(&alternates_path, "info/alternates");
> +
> + strbuf_reset(alternates_info);
> + strbuf_addbuf(alternates_info, &alternates_path);
> + strbuf_complete_line(alternates_info);
> + strbuf_read_file(alternates_info, alternates_path.buf, 0);
> +}
> diff --git a/bugreport.h b/bugreport.h
> index 4f5e2d1b9a..74d1f79960 100644
> --- a/bugreport.h
> +++ b/bugreport.h
> @@ -36,3 +36,9 @@ void get_packed_object_summary(struct strbuf *obj_info);
> * previous contents of hook_info will be discarded.
> */
> void get_object_info_summary(struct strbuf *obj_info);
> +
> +/**
> + * Adds the contents of '.git/info/alternates'. The previous contents of
> + * alternates_info will be discarded.
> + */
> +void get_alternates_file(struct strbuf *alt_info);
> diff --git a/builtin/bugreport.c b/builtin/bugreport.c
> index 8aad33a9b0..0784bdc42a 100644
> --- a/builtin/bugreport.c
> +++ b/builtin/bugreport.c
> @@ -76,6 +76,10 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix)
> get_object_info_summary(&buffer);
> strbuf_write(&buffer, report);
>
> + add_header(report, "Alternates File");
> + get_alternates_file(&buffer);
> + strbuf_write(&buffer, report);
> +
> // Close file
> // open file in editor
> launch_editor(report_path, NULL, NULL);
> --
> 2.24.0.rc0.303.g954a862665-goog
>
>