GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — clibrowser/cligit/src/commands/cherry_pick.rs at main · allthingssecurity/clibrowser

Expand file tree

/

cherry_pick.rs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
39 lines (34 loc) · 1.23 KB
/

cherry_pick.rs

Copy path

File metadata and controls

39 lines (34 loc) · 1.23 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use anyhow::Result;
use crate::cli::CherryPickArgs;
use crate::error::GitError;
use crate::git_ctx::GitContext;
use crate::models::*;
use crate::output::OutputConfig;
pub fn execute(args: CherryPickArgs, ctx: &GitContext, out: &OutputConfig) -> Result<i32> {
let repo = &ctx.repo;
let obj = repo.revparse_single(&args.commit)?;
let commit = obj.peel_to_commit()?;
let sha = commit.id().to_string();
repo.cherrypick(&commit, None)?;
let index = repo.index()?;
if index.has_conflicts() {
let count = index.conflicts()?.count();
return Err(GitError::MergeConflict(count).into());
}
if !args.no_commit {
let mut index = repo.index()?;
let tree_oid = index.write_tree()?;
let tree = repo.find_tree(tree_oid)?;
let sig = repo.signature()?;
let head = repo.head()?.peel_to_commit()?;
let msg = commit.message().unwrap_or("cherry-pick");
repo.commit(Some("HEAD"), &sig, &sig, msg, &tree, &[&head])?;
repo.cleanup_state()?;
}
let result = WriteResult {
message: format!("Cherry-picked {}", &sha[..7.min(sha.len())]),
};
if out.json { out.print_json(&result); }
else { out.print_human(&result.message); }
Ok(0)
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.