From patchwork Sat Feb 1 20:16:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tobler X-Patchwork-Id: 13956386 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82CFA57C93 for ; Sat, 1 Feb 2025 20:20:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738441209; cv=none; b=FVlJ+ekZ16kn1KcSZmUcXGbJjm6tSptg31uh3OKrFKb9HDj6frAPHDyJR2iBfPghOmFDAv+4tf5MCmbwhn7yOWHVbuE69WIG0OtLEajHx5d6CtLIHOrc0ehr41oTuQp/Tn45IGQpTXewuh7Y+rg6TLY79fKk3TFU0537G6sDQT0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738441209; c=relaxed/simple; bh=9W7dMn1Qku0x98lJjGot4hKO77JvknffjmFMtnrtMB8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZL+b2H831PC/DUAhutZLPHnHeoBoUZdIsRhpWohXhGiod9o8xSCZ0G7S6spA8/9KWlDpQfY8RQ+0Pmv0blo/M7wZP4E0Ihr/lD2hUO3l25MpDcR+pNWTuu3HDm9RAXB8Mr2wOeFjPDMoG1RUFyJxgcWe/+ZY1ACJ44Qc69EFkRY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RgmzOldo; arc=none smtp.client-ip=209.85.167.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RgmzOldo" Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3ebb4aae80dso1392161b6e.2 for ; Sat, 01 Feb 2025 12:20:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738441206; x=1739046006; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CHYWLJK55mooskMg01y7EmX2oDf94DQEr+i1mU/ip6k=; b=RgmzOldoYWrnmS0nh5HSIiD1FrT2hhxlu2a0bbKjIYT/5LmMM+eRn2yLdxRUijCCrC oecOuuTSlh9tkCFDdIcN/e9gtDi56sZAf6Nu3K9yruu6yV1iDYpOZ3r2nibsp4V8Y7qG 6D6A0S/RuEkltqV5L+tB3XCqwEmLKWY+E1wdO6/nKUMbt+NzV0PwcijBWvr+trJ6WgkC AhzmIR/KwvZ/w2DD46ebKZH1DNkDWLs50OmIUetREO17+g8fwzb+YdKLaGsQzLfCksbC 3rSZOPqzOJIosmh1GFRoWZU1sigNRYg5dnj1g3U6G1ZR4gBISNOWV5ShLLeTScctoBWY Mx2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738441206; x=1739046006; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CHYWLJK55mooskMg01y7EmX2oDf94DQEr+i1mU/ip6k=; b=m03md0QIFRgyw1DtZJnRYmib8kfpxmPdS6I6SFk1OQ2ZYqlBDBxdCG8ui2kAXyrkaV nMxXZRWwDKqrbea8GzLJim1XTaaqe+LErGsGw6xXiqx40xqdvexYQxsaVlUxXrYFh1x6 gf41B3nzb9Hj2xPbflb3vslcAjiUzwjDvV/C4HdVA2Uv3kTT6VC9VRKfhw1hZzeexLhb cn2I/ZiF62Zj3pTyjp6WAvmPImNQfkmm/o0kBXECycXzW1jJgi/Ht8KhcuXmpFigitY8 1Upn8IPxB1GiXnMEMaoBJD5QgOI8B2o6ozbOX+1B4qzuwLK8OnjdzTy8Y5av3WDzPRar A0ow== X-Gm-Message-State: AOJu0YyAb0MXPB6gHj17RK1Cn6Zaj4U2tt4R55Q1dy+6B7jJyJyKnH3I CblgCcEph3R7WC8kWdN/VyJYRo92L9njzEEEtTxTh1in78ELlACmEWdtKw== X-Gm-Gg: ASbGncvhxLQLlty6Gd2YX9Rncj4SNOmPKSqlNAPQYvIwrOSVRs21Cj0lp9gemCkleWR ZKk+MwvoNauIOnA49Z/9OX0zQdYE/e44shFLFk6x3Zxe5tMS2i1XPUZEMSIHF6sF6KhEh/TlIV3 dxANg+9ynoCSFhDsjXBc18YoPGSWc2YkDpubuUT94s/ztSEdhoUoBb2hD2NFdfUALJ3Bw/1pkux JQM9/s7mjg68+BM0k10zwKWACHVAf1Lw96GmIsUsTsRsPnLwqfi9h4G9zuamueDvzP25TYV6lqc mFKTeIBC6Kp0cGOEKYKYlfs= X-Google-Smtp-Source: AGHT+IH80IOiklwBeN0m/gF2iTYfxz/AMrMmexM8prgJxcxJOWjRR211/eqf8BofLfD9MOPUaxzw8Q== X-Received: by 2002:a05:6808:229e:b0:3ea:367e:db44 with SMTP id 5614622812f47-3f3239ed577mr10445881b6e.3.1738441206256; Sat, 01 Feb 2025 12:20:06 -0800 (PST) Received: from denethor.localdomain ([136.50.74.45]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3f3332bb032sm1588336b6e.0.2025.02.01.12.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Feb 2025 12:20:05 -0800 (PST) From: Justin Tobler To: git@vger.kernel.org Cc: christian.couder@gmail.com, Justin Tobler Subject: [PATCH v3 1/4] quote: add c quote flag to ignore core.quotePath Date: Sat, 1 Feb 2025 14:16:55 -0600 Message-ID: <20250201201658.11562-2-jltobler@gmail.com> X-Mailer: git-send-email 2.48.1.157.g3b0d05c4a7 In-Reply-To: <20250201201658.11562-1-jltobler@gmail.com> References: <20250110053417.2602109-2-jltobler@gmail.com> <20250201201658.11562-1-jltobler@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The output of `cq_must_quote()` is affected by `core.quotePath`. This is undesirable for operations that want to ensure consistent output independent of config settings. Introduce the `CQUOTE_IGNORE_CONFIG` flag for the `quote_c_style*` functions which when set makes `cq_must_quote()` always follow the default behavior (core.quotePath=true) regardless of how its set in the config. Signed-off-by: Justin Tobler --- quote.c | 14 ++++++++------ quote.h | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/quote.c b/quote.c index b9f6bdc775..d129c1de70 100644 --- a/quote.c +++ b/quote.c @@ -232,21 +232,22 @@ static signed char const cq_lookup[256] = { /* 0x80 */ /* set to 0 */ }; -static inline int cq_must_quote(char c) +static inline int cq_must_quote(char c, int ignore_config) { - return cq_lookup[(unsigned char)c] + quote_path_fully > 0; + return cq_lookup[(unsigned char)c] + (quote_path_fully || ignore_config) > 0; } /* returns the longest prefix not needing a quote up to maxlen if positive. This stops at the first \0 because it's marked as a character needing an escape */ -static size_t next_quote_pos(const char *s, ssize_t maxlen) +static size_t next_quote_pos(const char *s, ssize_t maxlen, int ignore_config) { size_t len; if (maxlen < 0) { - for (len = 0; !cq_must_quote(s[len]); len++); + for (len = 0; !cq_must_quote(s[len], ignore_config); len++); } else { - for (len = 0; len < maxlen && !cq_must_quote(s[len]); len++); + for (len = 0; + len < maxlen && !cq_must_quote(s[len], ignore_config); len++); } return len; } @@ -282,13 +283,14 @@ static size_t quote_c_style_counted(const char *name, ssize_t maxlen, } while (0) int no_dq = !!(flags & CQUOTE_NODQ); + int ignore_config = !!(flags & CQUOTE_IGNORE_CONFIG); size_t len, count = 0; const char *p = name; for (;;) { int ch; - len = next_quote_pos(p, maxlen); + len = next_quote_pos(p, maxlen, ignore_config); if (len == maxlen || (maxlen < 0 && !p[len])) break; diff --git a/quote.h b/quote.h index 0300c29104..2a793fbef6 100644 --- a/quote.h +++ b/quote.h @@ -83,7 +83,8 @@ int sq_dequote_to_strvec(char *arg, struct strvec *); int unquote_c_style(struct strbuf *, const char *quoted, const char **endp); /* Bits in the flags parameter to quote_c_style() */ -#define CQUOTE_NODQ 01 +#define CQUOTE_NODQ (1u << 0) +#define CQUOTE_IGNORE_CONFIG (1u << 1) size_t quote_c_style(const char *name, struct strbuf *, FILE *, unsigned); void quote_two_c_style(struct strbuf *, const char *, const char *, unsigned); From patchwork Sat Feb 1 20:16:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tobler X-Patchwork-Id: 13956387 Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46CF71CDFBC for ; Sat, 1 Feb 2025 20:20:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738441210; cv=none; b=Jo02wVHAzemz6j8JTF4RSb35eq1i14k0zTk1z3zX1N2bpde886O1eRca+HSuZ8cOoON0OXgUYEvm2UAm8Zixhqw25Uam6YWjC+lbqnwFB8KDg5C5Fc0LXt/LC6/fE/ibrDdArJQuBwStdufVNqQ2ya6VDbMP3Y9RHnKQ+N97NBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738441210; c=relaxed/simple; bh=64lgMiWh+2Ze1k7XBTu/SfF0i8j7YxNOKSVW3IWYdaA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ihpf+LSNcRhHEWQzmiYi3I28d8M2mmEUsIMJoqwn39I5osnrbqUnlQsXkc10d1AaewEwtA8T8OLktyjkfwpVEFIU4M48xFnBuBiWwsFl7m1CdfFBOTgYoplusIXXTzuQs8BdqH6AxqgHCcc7bSIfC//Dtb5aEOhd0btGU+73hpw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=L1i3Ulm0; arc=none smtp.client-ip=209.85.167.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="L1i3Ulm0" Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3eb8559b6b0so1880970b6e.1 for ; Sat, 01 Feb 2025 12:20:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738441208; x=1739046008; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YhkHmzFPePb+VueEvMYmbYngo1a6iUd/ux8IdFi6HRI=; b=L1i3Ulm01rli0dtcLwsfFZTmZeLSVtB6/30ObNWhpJRvIKwDf3TTXxwKOJRdYJPBdI peXO/TE1mh2/l64FZ5eO5a2NOavUjpvCmu0weCeRussiR8cdqtTtJOtRSzHpaFZSkC9+ +iZOkQ5WT/jRckzZxRmTC/iSW6Et4L5rI7C65GogAWvA/weFv6DiZEhJx+yAEdPIygQC M6enoqF1w5VjV+Rb8f88gyOrh+pXF6PtgcOJQoKgc0RfDzBiaVFIoE7jyeauRI+p4jJz 4xNjYlgQVUoRSJkg2Dh2bM1bWQNQD0f1bm4ODQnWSrms4fNQ0bAyxxItRLvswdXGWU2z XOkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738441208; x=1739046008; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YhkHmzFPePb+VueEvMYmbYngo1a6iUd/ux8IdFi6HRI=; b=MCbXn8a8kdXeUGaA9dcbVQLDAx1zj8c0NyUsHKcLEnThr8bZ7hulnZBeX38oTrpy6f wEIQuC9a3hTZ7JUa7NmrCsqzq7TbMySbOFEfy0pJLow7tBoZ8Q4XqpGheRZyeJ+1vYCP dzIGjZIZ2unED5Xt7FOAj5xFUsIicAKthbpO6Dd+LKzEWqCLh7bI79jb+nxvXjVHbEpW 9+ncEIw4aPAiEPkDjjnLNxozlRk8J7kMG/Q2AcWXEnwlddanw2EJY/yJTSZF5Pu+l1OZ xmZ5JNZ7KTeosiK3zQc5mWKMlwU7n7V996yu/fFRfDHo8vNtfPRMt4Vbp+3hr1VpBcL1 tRTw== X-Gm-Message-State: AOJu0YwyOAUhhBrnJK/k3hEpB6CtDM3VE4y+OeLKikDyBnOz48K4ROSZ kr1DEdllu2KPI5/gumFpONGRmlZQAyQubdF3qeAR63hHokum9C1i9AQsXw== X-Gm-Gg: ASbGncvb/rYdb/zW3FKo7fW4Qr/pxM/VivZfRMUIRs39xQmoFfE6EO06TyfpzFKvpy7 a8ENObRAcIHQPyMuIsMLTWpA4p7uLoRmzwbqxFRcclYA5P6jJWM4ifB0ZgOuxFWBN3Itu6dsS0d iAwzfF5LH49PMY2IDsGZw9vduJLKMM/uhf4hGAP7R3ZN9kI6UbfZG9Sh5yIdFeCT+Y5Iy4QpOBa LqoJqgFWG1S/s4BfIkuQxDi+NfTmMB/KRorYbLwyETEzPLgn3cquiYmaXkHK78IHdRCHQI7joiH Rfw7xSEY+eILFK0i/GlWFKc= X-Google-Smtp-Source: AGHT+IF+n/z1y9tb/iRnrGvfrEx/WU5JhFuwHsJrG3OHvSSkI9ziBUzSOkIfJxcpWyFL7DsGpsz5Rg== X-Received: by 2002:a05:6808:3386:b0:3ef:27fe:e969 with SMTP id 5614622812f47-3f323a3ea70mr11019672b6e.11.1738441207831; Sat, 01 Feb 2025 12:20:07 -0800 (PST) Received: from denethor.localdomain ([136.50.74.45]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3f3332bb032sm1588336b6e.0.2025.02.01.12.20.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Feb 2025 12:20:07 -0800 (PST) From: Justin Tobler To: git@vger.kernel.org Cc: christian.couder@gmail.com, Justin Tobler Subject: [PATCH v3 2/4] quote: add quote_path() flag to ignore config Date: Sat, 1 Feb 2025 14:16:56 -0600 Message-ID: <20250201201658.11562-3-jltobler@gmail.com> X-Mailer: git-send-email 2.48.1.157.g3b0d05c4a7 In-Reply-To: <20250201201658.11562-1-jltobler@gmail.com> References: <20250110053417.2602109-2-jltobler@gmail.com> <20250201201658.11562-1-jltobler@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The `quote_path()` function invokes `quote_c_style_counted()` to handle quoting. This means the output `quote_path()` is ultimately affected by `core.quotePath` configuration. In a subsequent commit, `quote_path()` will be used in a scenario where the output should remain consistent regardless of the current configuration. Introduce the `QUOTE_PATH_IGNORE_CONFIG` flag for `quote_path()`which when set instructs the underlying `quote_c_style_counted()` to also ignore the `core.quotePath` configuration when executed. Signed-off-by: Justin Tobler --- quote.c | 13 ++++++++++--- quote.h | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/quote.c b/quote.c index d129c1de70..baec34ca94 100644 --- a/quote.c +++ b/quote.c @@ -370,10 +370,18 @@ char *quote_path(const char *in, const char *prefix, struct strbuf *out, unsigne { struct strbuf sb = STRBUF_INIT; const char *rel = relative_path(in, prefix, &sb); - int force_dq = ((flags & QUOTE_PATH_QUOTE_SP) && strchr(rel, ' ')); + unsigned cquote_flags = 0; + int force_dq = 0; strbuf_reset(out); + if ((flags & QUOTE_PATH_QUOTE_SP) && strchr(rel, ' ')) { + force_dq = 1; + cquote_flags &= CQUOTE_NODQ; + } + if (flags & QUOTE_PATH_IGNORE_CONFIG) + cquote_flags &= CQUOTE_IGNORE_CONFIG; + /* * If the caller wants us to enclose the output in a dq-pair * whether quote_c_style_counted() needs to, we do it ourselves @@ -381,8 +389,7 @@ char *quote_path(const char *in, const char *prefix, struct strbuf *out, unsigne */ if (force_dq) strbuf_addch(out, '"'); - quote_c_style_counted(rel, strlen(rel), out, NULL, - force_dq ? CQUOTE_NODQ : 0); + quote_c_style_counted(rel, strlen(rel), out, NULL, cquote_flags); if (force_dq) strbuf_addch(out, '"'); strbuf_release(&sb); diff --git a/quote.h b/quote.h index 2a793fbef6..84903951ef 100644 --- a/quote.h +++ b/quote.h @@ -94,7 +94,8 @@ void write_name_quoted_relative(const char *name, const char *prefix, /* quote path as relative to the given prefix */ char *quote_path(const char *in, const char *prefix, struct strbuf *out, unsigned flags); -#define QUOTE_PATH_QUOTE_SP 01 +#define QUOTE_PATH_QUOTE_SP (1u << 0) +#define QUOTE_PATH_IGNORE_CONFIG (1u << 1) /* quoting as a string literal for other languages */ void perl_quote_buf(struct strbuf *sb, const char *src); From patchwork Sat Feb 1 20:16:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tobler X-Patchwork-Id: 13956388 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4ACDE1C3F00 for ; Sat, 1 Feb 2025 20:20:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738441213; cv=none; b=ZIpFog7EO+flHPl0Ppa3IFsvm6J5iRfPOeOXYc10CA3Z5HVShaX0lfCmTUgCsdPnnfjzBlNIGDHqdNpPpGOzS/KQQU1eggZohxUkkDc8ipT2iWafP2WjYy177ZtDmts2xGiUnoiidlxOUWgR4qKjPjFoYia/4gtloTneJ+NDnaA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738441213; c=relaxed/simple; bh=qXBb5S+au/MqwTyyMLVXC7GzTok2nG96taBsZNZeCDg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rEWYsIUkefO885R4NyShGMqL48iVTQ3xPn7B20vnZWau6kftJ6gCDgMMkY82/fDjK9BBcMfrzUK+7TnUbTdxHnHif6DMl4NakeZ+q3S7lUupmvj8NAADAOusDwbFAVezJX/BzNcI5wSPJGWJQtDte01/hiyzdqYsEeWonmiQxEU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=POBQ9g84; arc=none smtp.client-ip=209.85.167.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="POBQ9g84" Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3ebadbb14dcso1312981b6e.3 for ; Sat, 01 Feb 2025 12:20:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738441210; x=1739046010; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=g75BUhcT48DLcnjFe2zYhcjHhwEwmuhsmGwotE+RA/w=; b=POBQ9g84uggq7Z5+vEIQaVhuheP3Gg8/Lajw5yO4HbUi69rLI1TtKmpAhOpQHUgkQQ lrcEGAOF6nFDlwh2W9Akri62eqhdfSr6U+y4xKp5m6CJHs6+gKadCv3Gv7tzCEnVi4RK Uif+Nde1LpTPsdqIYNQxoTRf/kpPlFqYe0FAwlfYkAhrMNwEcZmqoVlV9rwzE6gw1OyT dfh0DQf73IT6wujwZU1RGFN+7HjD7eZMT6xSlebZEe5obtD3JGGKRu0UvJIYXb5HGxwN KDcrtH0IT6T2tGDDy0J8lUrlhc5b31INsbEcaly2u987UMel8FMm2Bc7DDV9CqkFOpks 7zpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738441210; x=1739046010; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g75BUhcT48DLcnjFe2zYhcjHhwEwmuhsmGwotE+RA/w=; b=uvOqtctpCXdDKK8ZDk2J+NQS9NcPxEHWV9NMvz6W0164JbWKYzwXxKDt91ipPSiDZz I+rxWAFGMdogwHBFK0uj/uUc3PD7w/Eamq78wChwF7fIMHnFGSnCwRqB3n3mWPElGEiw BErOyBrdNT5CHH3u65xRDk5RXLtfcQSr5AwvYxHtGUBWWjQ1pztnSplyPmHswH8Ut76f N3csXbWRz1Qot+Srl1dpLvnu9ekKsQwHbnvmKf0mAY8RSz5gSKnLqj/W56JAba2KrvcV x9HpPfnQF/v7kyqxLNW2rqNI+WpaaiMaEplZ+mQKA9Q3F1vtEDPMl8FgDw5vYpCyg50z 1Y7w== X-Gm-Message-State: AOJu0Yzy0TwM2gq/ZWdh87HrIr1wslzZrpxTZs0NbmwGX9HD07rPfnNb lK86OroovQrt4g2Wu0lKkVkLK45M2DxS8adRydJqPLprqNremWuxNMBEig== X-Gm-Gg: ASbGncsUBizMUTR0z06TjxdWusSCGtGI5DwrvmSY+9ZnInLXJ51F7D8mnvWOSO9Ufhu HNpc+puGa/7tIO4xzmYdTisyKJiuvEiX2FympQ2rqsfo8dw7DKZCktONFITKATVyoawZm5+jPB9 lQuHcf4eW/Uv7Oi+hWLGeRkh53EqF5KMT2vR8Dk/f6NlzCyVH8kbu0vblgzI9Hfi7CKPkCxAD4/ wWrC9SXn15MhUdBoIZQQT3/14C84qCGWU+izLiuaaK4YAByeTeAJ36j72E6v8gNJstIY7HDuAu/ COiC8q1j4H+zj5mljFh4C+E= X-Google-Smtp-Source: AGHT+IHkwqGDnD0A3WfD0zI4LkbfAzJ0kmmMps5cTCWPdXkR0m5vTrdmSd0pJXR9FcbV3KyOH5TEPA== X-Received: by 2002:a05:6808:1a06:b0:3ec:d30f:60e3 with SMTP id 5614622812f47-3f323b7318amr12473491b6e.39.1738441209622; Sat, 01 Feb 2025 12:20:09 -0800 (PST) Received: from denethor.localdomain ([136.50.74.45]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3f3332bb032sm1588336b6e.0.2025.02.01.12.20.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Feb 2025 12:20:09 -0800 (PST) From: Justin Tobler To: git@vger.kernel.org Cc: christian.couder@gmail.com, Justin Tobler Subject: [PATCH v3 3/4] rev-list: add print-info action to print missing object path Date: Sat, 1 Feb 2025 14:16:57 -0600 Message-ID: <20250201201658.11562-4-jltobler@gmail.com> X-Mailer: git-send-email 2.48.1.157.g3b0d05c4a7 In-Reply-To: <20250201201658.11562-1-jltobler@gmail.com> References: <20250110053417.2602109-2-jltobler@gmail.com> <20250201201658.11562-1-jltobler@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Missing objects identified through git-rev-list(1) can be printed by setting the `--missing=print` option. Additional information about the missing object, such as its path and type, may be present in its containing object. Add the `print-info` missing action for the `--missing` option that, when set, prints additional insight about the missing object inferred from its containing object. Each line of output for a missing object is in the form: `? [=]...`. The `=` pairs containing additional information are separated from each other by a SP. The value is encoded in a token specific fashion, but SP or LF contained in value are always expected to be represented in such a way that the resulting encoded value does not have either of these two problematic bytes. This format is kept generic so it can be extended in the future to support additional information. For now, only a missing object path info is implemented. It follows the form `path=` and specifies the full path to the object from the top-level tree. A path containing SP or special characters is enclosed in double-quotes in the C style as needed. In a subsequent commit, missing object type info will also be added. Signed-off-by: Justin Tobler --- Documentation/rev-list-options.txt | 16 +++++ builtin/rev-list.c | 102 ++++++++++++++++++++++++----- t/t6022-rev-list-missing.sh | 52 +++++++++++++++ 3 files changed, 153 insertions(+), 17 deletions(-) diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index 459e5a02f5..0bea9d4ad3 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -1024,6 +1024,22 @@ Unexpected missing objects will raise an error. The form '--missing=print' is like 'allow-any', but will also print a list of the missing objects. Object IDs are prefixed with a ``?'' character. + +The form '--missing=print-info' is like 'print', but will also print additional +information about the missing object inferred from its containing object. The +information is all printed on the same line with the missing object ID in the +form: `? [=]...`. The `=` pairs containing +additional information are separated from each other by a SP. The value is +encoded in a token specific fashion, but SP or LF contained in value are always +expected to be represented in such a way that the resulting encoded value does +not have either of these two problematic bytes. Each `=` may be +one of the following: ++ +-- +* The `path=` shows the path of the missing object inferred from a + containing object. A path containing SP or special characters is enclosed in + double-quotes in the C style as needed. +-- ++ If some tips passed to the traversal are missing, they will be considered as missing too, and the traversal will ignore them. In case we cannot get their Object ID though, an error will be raised. diff --git a/builtin/rev-list.c b/builtin/rev-list.c index 3196da7b2d..4a45a4e555 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -22,7 +22,10 @@ #include "progress.h" #include "reflog-walk.h" #include "oidset.h" +#include "oidmap.h" #include "packfile.h" +#include "quote.h" +#include "strbuf.h" static const char rev_list_usage[] = "git rev-list [] ... [--] [...]\n" @@ -73,11 +76,16 @@ static unsigned progress_counter; static struct oidset omitted_objects; static int arg_print_omitted; /* print objects omitted by filter */ -static struct oidset missing_objects; +struct missing_objects_map_entry { + struct oidmap_entry entry; + const char *path; +}; +static struct oidmap missing_objects; enum missing_action { MA_ERROR = 0, /* fail if any missing objects are encountered */ MA_ALLOW_ANY, /* silently allow ALL missing objects */ MA_PRINT, /* print ALL missing objects in special section */ + MA_PRINT_INFO, /* same as MA_PRINT but also prints missing object info */ MA_ALLOW_PROMISOR, /* silently allow all missing PROMISOR objects */ }; static enum missing_action arg_missing_action; @@ -101,7 +109,46 @@ static off_t get_object_disk_usage(struct object *obj) return size; } -static inline void finish_object__ma(struct object *obj) +static void add_missing_object_entry(struct object_id *oid, const char *path) +{ + struct missing_objects_map_entry *entry; + + if (oidmap_get(&missing_objects, oid)) + return; + + CALLOC_ARRAY(entry, 1); + entry->entry.oid = *oid; + if (path) + entry->path = xstrdup(path); + oidmap_put(&missing_objects, entry); +} + +static void print_missing_object(struct missing_objects_map_entry *entry, + int print_missing_info) +{ + struct strbuf sb = STRBUF_INIT; + + if (!print_missing_info) { + printf("?%s\n", oid_to_hex(&entry->entry.oid)); + return; + } + + if (entry->path && *entry->path) { + struct strbuf path = STRBUF_INIT; + + strbuf_addstr(&sb, " path="); + quote_path(entry->path, NULL, &path, + QUOTE_PATH_QUOTE_SP | QUOTE_PATH_IGNORE_CONFIG); + strbuf_addbuf(&sb, &path); + + strbuf_release(&path); + } + + printf("?%s%s\n", oid_to_hex(&entry->entry.oid), sb.buf); + strbuf_release(&sb); +} + +static inline void finish_object__ma(struct object *obj, const char *name) { /* * Whether or not we try to dynamically fetch missing objects @@ -119,7 +166,8 @@ static inline void finish_object__ma(struct object *obj) return; case MA_PRINT: - oidset_insert(&missing_objects, &obj->oid); + case MA_PRINT_INFO: + add_missing_object_entry(&obj->oid, name); return; case MA_ALLOW_PROMISOR: @@ -152,7 +200,7 @@ static void show_commit(struct commit *commit, void *data) if (revs->do_not_die_on_missing_objects && oidset_contains(&revs->missing_commits, &commit->object.oid)) { - finish_object__ma(&commit->object); + finish_object__ma(&commit->object, NULL); return; } @@ -268,12 +316,11 @@ static void show_commit(struct commit *commit, void *data) finish_commit(commit); } -static int finish_object(struct object *obj, const char *name UNUSED, - void *cb_data) +static int finish_object(struct object *obj, const char *name, void *cb_data) { struct rev_list_info *info = cb_data; if (oid_object_info_extended(the_repository, &obj->oid, NULL, 0) < 0) { - finish_object__ma(obj); + finish_object__ma(obj, name); return 1; } if (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT) @@ -414,6 +461,12 @@ static inline int parse_missing_action_value(const char *value) return 1; } + if (!strcmp(value, "print-info")) { + arg_missing_action = MA_PRINT_INFO; + fetch_if_missing = 0; + return 1; + } + if (!strcmp(value, "allow-promisor")) { arg_missing_action = MA_ALLOW_PROMISOR; fetch_if_missing = 0; @@ -781,10 +834,18 @@ int cmd_rev_list(int argc, if (arg_print_omitted) oidset_init(&omitted_objects, DEFAULT_OIDSET_SIZE); - if (arg_missing_action == MA_PRINT) { - oidset_init(&missing_objects, DEFAULT_OIDSET_SIZE); + if (arg_missing_action == MA_PRINT || + arg_missing_action == MA_PRINT_INFO) { + struct oidset_iter iter; + struct object_id *oid; + + oidmap_init(&missing_objects, DEFAULT_OIDSET_SIZE); + oidset_iter_init(&revs.missing_commits, &iter); + /* Add missing tips */ - oidset_insert_from_set(&missing_objects, &revs.missing_commits); + while ((oid = oidset_iter_next(&iter))) + add_missing_object_entry(oid, NULL); + oidset_clear(&revs.missing_commits); } @@ -800,13 +861,20 @@ int cmd_rev_list(int argc, printf("~%s\n", oid_to_hex(oid)); oidset_clear(&omitted_objects); } - if (arg_missing_action == MA_PRINT) { - struct oidset_iter iter; - struct object_id *oid; - oidset_iter_init(&missing_objects, &iter); - while ((oid = oidset_iter_next(&iter))) - printf("?%s\n", oid_to_hex(oid)); - oidset_clear(&missing_objects); + if (arg_missing_action == MA_PRINT || + arg_missing_action == MA_PRINT_INFO) { + struct missing_objects_map_entry *entry; + struct oidmap_iter iter; + + oidmap_iter_init(&missing_objects, &iter); + + while ((entry = oidmap_iter_next(&iter))) { + print_missing_object(entry, arg_missing_action == + MA_PRINT_INFO); + free((void *)entry->path); + } + + oidmap_free(&missing_objects, true); } stop_progress(&progress); diff --git a/t/t6022-rev-list-missing.sh b/t/t6022-rev-list-missing.sh index 7553a9cca2..38afca6f09 100755 --- a/t/t6022-rev-list-missing.sh +++ b/t/t6022-rev-list-missing.sh @@ -145,4 +145,56 @@ do done done +for obj in "HEAD~1" "HEAD^{tree}" "HEAD:foo" "HEAD:foo/bar" "HEAD:baz baz" +do + test_expect_success "--missing=print-info with missing '$obj'" ' + test_when_finished rm -rf missing-info && + + git init missing-info && + ( + cd missing-info && + git commit --allow-empty -m first && + + mkdir foo && + echo bar >foo/bar && + echo baz >"baz baz" && + echo bat >bat\" && + git add -A && + git commit -m second && + + oid="$(git rev-parse "$obj")" && + path=".git/objects/$(test_oid_to_path $oid)" && + + case $obj in + HEAD:foo) + path_info=" path=foo" + ;; + HEAD:foo/bar) + path_info=" path=foo/bar" + ;; + "HEAD:baz baz") + path_info=" path=\"baz baz\"" + ;; + "HEAD:bat\"") + path_info=" path=\"bat\\\"\"" + ;; + esac && + + # Before the object is made missing, we use rev-list to + # get the expected oids. + git rev-list --objects --no-object-names \ + HEAD ^"$obj" >expect.raw && + echo "?$oid$path_info" >>expect.raw && + + mv "$path" "$path.hidden" && + git rev-list --objects --no-object-names \ + --missing=print-info HEAD >actual.raw && + + sort actual.raw >actual && + sort expect.raw >expect && + test_cmp expect actual + ) + ' +done + test_done From patchwork Sat Feb 1 20:16:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tobler X-Patchwork-Id: 13956389 Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C441A1CBE87 for ; Sat, 1 Feb 2025 20:20:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738441214; cv=none; b=PN6xTBDY+7qNevfXNZN1hFZz1BOQG0Ruu+QqddzvnHydCmvOf7wqs7cPNDgPAjkAb2yhIWkj6CiH1pDQ5ZWfUrCCAajGZpOx5xsFxSRTYiiq9xOpWxW4X/0rBlS0OnpYKAkXvsYGRLbtqyx6pTomEDzxQ+a5vHJthfhxrCEj2Zw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738441214; c=relaxed/simple; bh=gXJLtyvcSkqUbmZsllV1MYxcE6Vsp7c1nYHzdC/Runs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q8zZc9GXLQ6krHD46RFXa0Pb/B+AB3niWND9ojpBY4O+5IcYCKApFi4CZdPVJtS5LkU4pgqS1Rc2te/SuUq7Ei9cICvbcarrCYg8/A/juMsYMxeeeXCoX0cC+KG4PYGvWzKOMp1bCnJPxMHREpl2uWVaKzpPQiSzuaNBXTHobRA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dSvOpNbb; arc=none smtp.client-ip=209.85.167.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dSvOpNbb" Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-3eba7784112so1711747b6e.2 for ; Sat, 01 Feb 2025 12:20:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738441211; x=1739046011; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UIAVxO/hyNcU2z7+EW7A4eD5X/AtlgSjbCbPT1g7Ars=; b=dSvOpNbbhIwIGCWzGGa2bEdhzCCTGmXpKkp8SKUEeouWDLtF+kDRRkwRDhxAh/H1kQ KOwPawkqsDI9P5hvUhTLJC7WQ8jryWx1HwLFQWpgkA8mtCwkY2BN0SAx4ZhQ/I1ixUkq cH6TRZw9f77E1WumJGrxlgjhcpSOyke5IN/qnRo/Jrl0WpF0aeWOSqA8xFnOUikxTvSz UeYBhmd6oKES7FncG+npgbhg+judXxi4fF+L/CbxVHwYxpTw0jTd5RXZusq6Jb2y8DZd hKU0Acjg8DxCaPJTaueoimWZJpyIDjb6hS4OOhIPZc+Ksw4hm+HmBf5Zg3EVgZVN2lFz RxrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738441211; x=1739046011; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UIAVxO/hyNcU2z7+EW7A4eD5X/AtlgSjbCbPT1g7Ars=; b=TeqB9mvRh6ZZuaogAjqi5tBK3SIDPGc6niynrzXlwAbtteRhJnpDDbU1oC/gYXC2qS 5wJVia3306pGaOvjOS7ObfzsSJTw+qAk8fbMMkBhUNgO18CWQKWpCZa74U2DQ9t8rXVX ulsQdtDK+pGZr++sL3qwo4G3/KdpGDSi1YLBBaJQ4pUGHNjilF1lZFGiwIVcJRTt1HZz nXJ+rgr2raR2zj0VDXxMJv1YcauCGauZSDp1PTmx4P/Wox9VaPkCnn4yj4+CX84JDnpc fe7qfFt1kU/VVTjQd5Aqel6ROBXnAzVWcMSwq3ZWCQlj2wk5dtF6GeGaTPvbxDWvpzcR H33A== X-Gm-Message-State: AOJu0YxcYaG+SGHy4BM1EOr+Y/5qHhgThbvkKPz++ilsDp2hZ9TZMuDq R8ouW4WHfeZPCEaFAk2GKJ5/tpdWDVlybSm9bdVTf0EDmYx1Lv5l/ElBtQ== X-Gm-Gg: ASbGnctu5ucvij4WjTpkzYVSPZfhNFMQJfbEZfkcm41Kffu7IiMCnIQcXda7XR9VyCi UFEYSGL6n6AZl3ATa7kIIC0ZIsf5Hfh0Pqd1axhPQqtFi6Rj8+y3BLPIlu8J5VHriGV+tbj/Faf Ca+6nHkHZzxWUtBF/npOl7oWe3AOl7C/Aj5JjMw6i/dKtej1oA901FosssbczIChMp0MJuf0aAa XKQmhxz2IOZQ1lnpVB1e2CUoRqOzfmTmBgY65Naq050KsSG/5/NLMCW6q94aQLe200CSVgoPpYr R7jI1xFXe/Ed0N81gHxJgfI= X-Google-Smtp-Source: AGHT+IF/FlOhYcGx6eZ6Nfx5183fOXEfpY+1muZjjhn8P2LtI8hh9oH6J2Rv7DWJfD4QxnHp8bihtQ== X-Received: by 2002:a05:6808:15a4:b0:3eb:58b5:8614 with SMTP id 5614622812f47-3f323b674fbmr10215498b6e.29.1738441211650; Sat, 01 Feb 2025 12:20:11 -0800 (PST) Received: from denethor.localdomain ([136.50.74.45]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3f3332bb032sm1588336b6e.0.2025.02.01.12.20.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Feb 2025 12:20:10 -0800 (PST) From: Justin Tobler To: git@vger.kernel.org Cc: christian.couder@gmail.com, Justin Tobler Subject: [PATCH v3 4/4] rev-list: extend print-info to print missing object type Date: Sat, 1 Feb 2025 14:16:58 -0600 Message-ID: <20250201201658.11562-5-jltobler@gmail.com> X-Mailer: git-send-email 2.48.1.157.g3b0d05c4a7 In-Reply-To: <20250201201658.11562-1-jltobler@gmail.com> References: <20250110053417.2602109-2-jltobler@gmail.com> <20250201201658.11562-1-jltobler@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Additional information about missing objects found in git-rev-list(1) can be printed by specifying the `print-info` missing action for the `--missing` option. Extend this action to also print missing object type information inferred from its containing object. This token follows the form `type=` and specifies the expected object type of the missing object. Signed-off-by: Justin Tobler --- Documentation/rev-list-options.txt | 3 +++ builtin/rev-list.c | 11 ++++++++--- t/t6022-rev-list-missing.sh | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index 0bea9d4ad3..f10f78c600 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -1038,6 +1038,9 @@ one of the following: * The `path=` shows the path of the missing object inferred from a containing object. A path containing SP or special characters is enclosed in double-quotes in the C style as needed. ++ +* The `type=` shows the type of the missing object inferred from a + containing object. -- + If some tips passed to the traversal are missing, they will be diff --git a/builtin/rev-list.c b/builtin/rev-list.c index 4a45a4e555..963f96d031 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -79,6 +79,7 @@ static int arg_print_omitted; /* print objects omitted by filter */ struct missing_objects_map_entry { struct oidmap_entry entry; const char *path; + unsigned type; }; static struct oidmap missing_objects; enum missing_action { @@ -109,7 +110,8 @@ static off_t get_object_disk_usage(struct object *obj) return size; } -static void add_missing_object_entry(struct object_id *oid, const char *path) +static void add_missing_object_entry(struct object_id *oid, const char *path, + unsigned type) { struct missing_objects_map_entry *entry; @@ -118,6 +120,7 @@ static void add_missing_object_entry(struct object_id *oid, const char *path) CALLOC_ARRAY(entry, 1); entry->entry.oid = *oid; + entry->type = type; if (path) entry->path = xstrdup(path); oidmap_put(&missing_objects, entry); @@ -143,6 +146,8 @@ static void print_missing_object(struct missing_objects_map_entry *entry, strbuf_release(&path); } + if (entry->type) + strbuf_addf(&sb, " type=%s", type_name(entry->type)); printf("?%s%s\n", oid_to_hex(&entry->entry.oid), sb.buf); strbuf_release(&sb); @@ -167,7 +172,7 @@ static inline void finish_object__ma(struct object *obj, const char *name) case MA_PRINT: case MA_PRINT_INFO: - add_missing_object_entry(&obj->oid, name); + add_missing_object_entry(&obj->oid, name, obj->type); return; case MA_ALLOW_PROMISOR: @@ -844,7 +849,7 @@ int cmd_rev_list(int argc, /* Add missing tips */ while ((oid = oidset_iter_next(&iter))) - add_missing_object_entry(oid, NULL); + add_missing_object_entry(oid, NULL, 0); oidset_clear(&revs.missing_commits); } diff --git a/t/t6022-rev-list-missing.sh b/t/t6022-rev-list-missing.sh index 38afca6f09..3e2790d4c8 100755 --- a/t/t6022-rev-list-missing.sh +++ b/t/t6022-rev-list-missing.sh @@ -164,6 +164,7 @@ do oid="$(git rev-parse "$obj")" && path=".git/objects/$(test_oid_to_path $oid)" && + type_info=" type=$(git cat-file -t $oid)" && case $obj in HEAD:foo) @@ -184,7 +185,7 @@ do # get the expected oids. git rev-list --objects --no-object-names \ HEAD ^"$obj" >expect.raw && - echo "?$oid$path_info" >>expect.raw && + echo "?$oid$path_info$type_info" >>expect.raw && mv "$path" "$path.hidden" && git rev-list --objects --no-object-names \